I don't know if this is related but I have a simple class which
crashes if a CallSite is invoked more than a few hundred times.
Thanks,
Wei
import java.dyn.*;
public class MHLoop {
public static Integer add(Integer x, Integer y) {
return x + y;
}
public static void main(String...args) {
for(int i = 0; i < 100000; i++)
System.out.println(InvokeDynamic.<Integer>sum((Integer)i, (Integer)i));
}
static { Linkage.registerBootstrapMethod("linker" ); }
public static CallSite linker(Class<?> declaringClass, String name,
MethodType type) {
MethodHandle target = null;
try {
MethodType addType = MethodType.make(Integer.class, Integer.class,
Integer.class);
target = MethodHandles.lookup().findStatic(MHLoop.class, "add",
addType);
} catch (Exception e) {
e.printStackTrace();
}
if (null == target)
throw new InvokeDynamicBootstrapError("linkage failed:
" + name);
CallSite site = new CallSite(declaringClass, name, type);
site.setTarget(target);
return site;
}
}
_______________________________________________
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev