Hi John, hi all,
Doing some testing, I've found that a registerBootstrapMethod that take 
the a class
that will contain a linkage static method and a method name is convenient.

   public static
    void registerBootstrapMethod(Class<?> bootstrapLinkageClass, String 
name) {
        Class callc = Reflection.getCallerClass(2);
        MethodHandle bootstrapMethod =
            MethodHandles.findStaticFrom(callc, bootstrapLinkageClass, 
name, BOOTSTRAP_METHOD_TYPE);
        if (bootstrapMethod == null)
            throw new IllegalArgumentException("cannot find bootstrap 
method: "+name+" of "+bootstrapLinkageClass);
        Linkage.registerBootstrapMethod(callc, bootstrapMethod);
    }

This avoid to create a MethodHandle in the static init of the class 
containing an invokedynamic.
Also note that a Class like a String is a VM constant.

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

Reply via email to