> > Paul also points out areas where MethodHandles can replace the rather >> sticky reflection work that Clojure does now to massage calls to non-Clojure >> libraries. That's not entirely related to the invokedynamic stuff I'm >> working on, so I think I'll leave it to somebody else to take a stab at >> that... >> > > I wonder if it would be that difficult to replace the reflector code with > an invokedynamic. There is a way to get from a java.lang.reflect.Method to a > java.lang.invoke.MethodHandle (see > java.lang.invoke.MethodHandles.Lookup.unreflect). You could probably just > replace the code that emits a direct call to clojure.lang.Reflector to emit > an invokedynamic instruction that calls a bootstrap method that wraps the > Reflector code and just converts the Method into a MethodHandle for > bootstrapping. >
I think you're overstating the problem: reflection is ugly, but it only happens here during compilation. From then on, the compiled code does what it needs to do with the types. At least, that's my reading of it: you told me before that I was dead wrong here, and maybe I am! If I'm right, then I don't see a "gap" here that invokedynamic can help bridge. > But things always seem easier until you actually get into them. :) > Tell me about it! Getting invokedynamic to work was much harder than I thought. It doesn't help that the Clojure codebase is a) very non-canonical Java, and b) utterly undocumented. Also, there's very little documentation about these new JVM features. They involve various tricks having to do with frame stack accounting and signatures, and when you don't get it right, you get terrible exceptions from ASM or the JVM. In both cases, all they can tell you is that "you're doing it wrong." Not for the faint of heart, nor for people who hate assembly... -Tal -- 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