[jboss-user] [Javassist user questions] - problem initialize a local variable

gkorland do-not-reply at jboss.com
Fri Feb 15 11:33:03 EST 2008


I'm trying to add a local variable and then initialize it.
The code is pretty simple (define a local variable and use a static get() to assign a value):

method.addLocalVariable(LOCAL_VARIBALE_NAME, TEST_CLASS);
method.insertBefore(LOCAL_VARIBALE_NAME + "=" + TEST_CLASS.getName() + ".get();");

But I get the following error:
Exception in thread "main" java.lang.VerifyError: (class: org/test/main/AA, method: foo3 signature: ()V) Incompatible argument to function
	at org.test.main.Main.main(Main.java:24)

But if I switch it to:
method.insertBefore(LOCAL_VARIBALE_NAME + "=new " + TEST_CLASS.getName() + "();");

It works!

Any ideas?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129706#4129706

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129706

More information about the jboss-user mailing list