Ok, it seems the backport reach a version that can be published :)

How it works, it replace all call to invokedynamic (invokeinterface on 
java.dyn.Dynamic)
to a code rouhly equivalent to the one given in the spec :

        // x . invokedynamic["alpha",(Object,int)Object] (y, z)
        MethodHandle method1 = site1.target;
        if (method1 == null)
            return Linkage.bootstrapMethod(site1, x, new Object[] {y, z});
        return ((java.dyn.internal.mh.OIOInterface)method1).invoke(x, y, z);

There is one difference with the code given in the spec, the method 
handle is cast to an interface
(here java.dyn.internal.mh.OIOInterface). MethodHandle at callsite is 
tranformed to interface
in order to allow to invoke it.

There are to way to do this bycode enhancement, at compile-time using 
com.sun.dyn.main.Main
or at runtime using an agent (a java.lang.instrumentation one). The 
later is currently not very stable.

Example a compile time :
1) enhance the classes Sample1, Sample2 and Bootstrap
[EMAIL PROTECTED] invokedynamic-backport]$ java 
-Xbootclasspath/p:boot/classes:asm-3.1/lib/all/asm-all-3.1.jar -cp 
classes:. com.sun.dyn.main.Main Sample1 Sample2 Bootstrap
[EMAIL PROTECTED] invokedynamic-backport]$ cd gen
[EMAIL PROTECTED] gen]$ ls
Bootstrap.class  Sample1.class  Sample2.class

2) execute Sample1 (that declares the bootstrap method in the bytecode)
[EMAIL PROTECTED] gen]$ java 
-Xbootclasspath/p:../boot/classes:../asm-3.1/lib/all/asm-all-3.1.jar -cp 
. Sample1

3) execute Sample2 (that register its bootstrap method dynamically)
[EMAIL PROTECTED] gen]$ java 
-Xbootclasspath/p:../boot/classes:../asm-3.1/lib/all/asm-all-3.1.jar -cp 
. Sample2

enjoy,
Rémi


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM 
Languages" group.
To post to this group, send email to jvm-languages@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to