Crash with invokeDynamic on MethodMissing attempt

Wei Yin Teo weiyinteo at gmail.com
Wed May 20 14:24:12 PDT 2009


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;
   }
}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20090520/bae8a07a/attachment.html 


More information about the mlvm-dev mailing list