I have been updating the InvokeDynamicDemo toy project from my blog (and the meth/indy software in general).

Here's the driver routine for that demo:

import java.dyn.*;
import static java.dyn.MethodHandles.*;
import static java.dyn.MethodType.*;

public class Main {
static final Class[] CLASSES = { Hello.class, GetNameDemo.class, FidgetDemo.class };
    public static void main(String[] args) {
        for (Class c : CLASSES) {
            MethodHandle main = lookup().findStatic(c, "main",
                    make(void.class, String[].class));
            System.out.println("******** "+c.getName()+"."+main);
            main.<void>invoke(args);
        }
    }
}

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(...).

I will be pushing the code that actually runs this stuff in a day or two. (I know folks have been waiting for it.)

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.

(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.)

Best wishes,
-- John

_______________________________________________
mlvm-dev mailing list
[email protected]
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev

Reply via email to