On Tue, Jan 12, 2010 at 2:50 AM, Konrad Hinsen <konrad.hin...@fastmail.net> wrote: > On 11 Jan 2010, at 23:09, .Bill Smith wrote: > >> Every class object has a newInstance method: >> >> user=> (Class/forName "java.util.HashMap") >> java.util.HashMap >> user=> (.newInstance (Class/forName "java.util.HashMap")) >> #<HashMap {}> >> user=> >> >> Is that what you are looking for? > > It seems close, but it doesn't work for me. From experimenting I have the > impression that this works only for constructors with no arguments. > > I found some stuff in the Java docs on reflection that could work, but this > is getting very complicated... I'll first see if I can do without. >
Since Clojure already does this, you can borrow its implementation, found in clojure.lang.Reflector. In this case, see invokeConstructor. (clojure.lang.Reflector/invokeConstructor (class (ref "foo")) (to-array [42])) => #<r...@6ad3c65d: 42> Rich
-- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en