[jboss-user] [Javassist] New message: "Re: cannot access added Field in some cases. Please help."

jaikiran pai do-not-reply at jboss.com
Thu Feb 4 10:39:41 EST 2010

User development,

A new message was posted in the thread "cannot access added Field in some cases. Please help.":


Author  : jaikiran pai
Profile : http://community.jboss.org/people/jaikiran

You haven't posted your complete code nor the complete exception stacktrace (i reason i keep insisting on these is because they can contain vital information). Anyway, i just gave a quick try against 3.11.0.GA version javassist:
public class NewFieldTestCase extends TestCase
   public  void testSharedInterfaceAndSuperClass() throws Exception 
      CtClass dummyClass = ClassPool.getDefault().get("org.myapp.test.javassist.Dummy");
      CtField newIntField = new CtField(CtClass.intType,"myInt",dummyClass);
      CtMethod dummyMethod = dummyClass.getDeclaredMethod("dummyMethod");
      dummyMethod.insertBefore("myInt = 10;");
      byte[] modifiedDummyClassBytes = dummyClass.toBytecode();
      assertTrue("Empty bytes", modifiedDummyClassBytes.length > 0);

Works fine. Test case passes, no exceptions thrown.


To reply to this message visit the message page: http://community.jboss.org/message/524192#524192

More information about the jboss-user mailing list