If I have the following class:
`
public class ClojureTestBean {
private java.util.Map foo;
public void setFoo(Map foo) {
this.foo = foo;
}
public Map getFoo() {
return foo;
}
}
`
And I run the following clojure:
`
(def bean-instance (ClojureTestBean.))
(. bean-instance setFoo {"bar" "baz"})
(def bean-instance-as-map (from-java bean-instance))
(def new-bean-instance (to-java ClojureTestBean bean-instance-as-map))
`
The final line throws a {{java.lang.InstantiationException: java.util.Map}} exception (full stack trace found below). It looks like there's a {{to-java}} method that, when it gets a {{APersistentMap}}, tries to create an instance of the type of the parameter which in this case is a {{Map}} interface, which of course cannot be instantiated.
I'm wondering why the {{APersistentMap}} wouldn't be passed in directly, as it implements the {{Map}} interface?
`
CompilerException java.lang.InstantiationException: java.util.Map, compiling:(scratchpad.clj:13:24)
java.lang.InstantiationException: java.util.Map, compiling:(scratchpad.clj:13:24)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3628)
at clojure.lang.Compiler$DefExpr.eval(Compiler.java:439)
at clojure.lang.Compiler.eval(Compiler.java:6787)
at clojure.lang.Compiler.load(Compiler.java:7227)
at user$eval1676.invoke(form-init2280240325964091253.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6782)
at clojure.lang.Compiler.eval(Compiler.java:6745)
at clojure.core$eval.invoke(core.clj:3081)
at clojure.main$repl$read_eval_print__7099$fn__7102.invoke(main.clj:240)
at clojure.main$repl$read_eval_print__7099.invoke(main.clj:240)
at clojure.main$repl$fn__7108.invoke(main.clj:258)
at clojure.main$repl.doInvoke(main.clj:258)
at clojure.lang.RestFn.invoke(RestFn.java:1523)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__609.invoke(interruptible_eval.clj:53)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invoke(core.clj:630)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1868)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:51)
at clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__651$fn__654.invoke(interruptible_eval.clj:183)
at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__644.invoke(interruptible_eval.clj:152)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.InstantiationException: java.util.Map
at java.lang.Class.newInstance(Class.java:359)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:313)
at clojure.java.data$fn__247.invoke(data.clj:95)
at clojure.lang.MultiFn.invoke(MultiFn.java:233)
at clojure.java.data$make_setter_fn$fn__232.invoke(data.clj:55)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invoke(core.clj:630)
at clojure.java.data$fn__247.invoke(data.clj:101)
at clojure.lang.MultiFn.invoke(MultiFn.java:233)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3623)
`