Linkage.registerBootstrapMethod
Rémi Forax
forax at univ-mlv.fr
Sat May 2 16:06:01 PDT 2009
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
More information about the mlvm-dev
mailing list