<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I have been updating the InvokeDynamicDemo toy project from my blog (and the meth/indy software in general).</div><div><br></div><div>Here's the driver routine for that demo:</div><div><br></div><div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'">import java.dyn.*;</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'">import static java.dyn.MethodHandles.*;</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'">import static java.dyn.MethodType.*;</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"><br></font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'">public class Main {</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"> static final Class[] CLASSES = { Hello.class, GetNameDemo.class, FidgetDemo.class };</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"> public static void main(String[] args) {</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"> for (Class c : CLASSES) {</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"> MethodHandle main = lookup().findStatic(c, "main",</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"> make(void.class, String[].class));</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"> System.out.println("******** "+c.getName()+"."+main);</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"> main.<void>invoke(args);</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"> }</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'"> }</font></div><div><font class="Apple-style-span" face="'Lucida Sans Typewriter'">}</font></div><div><br></div><div>The import-statics reduce the verbosity, but (to me at least) it's still readable. I'm thinking maybe we should rename "make" to "type", as in MethodType.type(...) or for short just type(...).</div><div><br></div><div>I will be pushing the code that actually runs this stuff in a day or two. (I know folks have been waiting for it.)</div><div><br></div><div>Here's a bit of good news: I just pushed the experimental javac changes into the TL/langtools integration area, so that we can actually write the code above.</div><div><br></div><div>(N.B. The javac support is subject to change, if we decide there's a better design for the language support. Anybody who followed Neal's closures design, or the earlier debates about internal vs. external iterator APIs, knows that delicate problems arise when checked exceptions mix with function pointers.)</div><div><br></div><div>Best wishes,</div><div>-- John</div><div><br></div></div></body></html>