4 Replies Latest reply: Feb 21, 2008 8:35 AM by Martin Burger RSS

Byte code limits?

Tom Traughber Newbie

Are there limits (beyond normal VM limits) on how much code can be generated for a class? In my experiments it appears that after roughly 8,200 statements within a class, the offsets in the opcode get stored wrong to where I get a ClassCastException thrown from within ConstPool.getMethodrefName(). It appears an instance of NameAndTypeInfo is being returned instead of a MethodrefInfo.

  • 1. Re: Byte code limits?
    Martin Burger Newbie

    Hello!

    I have similar problems, while instrumenting classes I get various exceptions:

    Caused by: java.lang.NullPointerException
     at javassist.bytecode.ConstPool.getInterfaceMethodrefClassName(ConstPool.java:413)
     at javassist.expr.MethodCall.getClassName(MethodCall.java:91)
     at javassist.expr.MethodCall.getCtClass(MethodCall.java:75)
     at javassist.expr.MethodCall.getMethod(MethodCall.java:114)


    And:

    Caused by: java.lang.ClassCastException: javassist.bytecode.ClassInfo
     at javassist.bytecode.ConstPool.getFieldrefClassName(ConstPool.java:254)
     at javassist.expr.FieldAccess.getClassName(FieldAccess.java:97)
     at javassist.expr.FieldAccess.getCtClass(FieldAccess.java:89)
     at javassist.expr.FieldAccess.getField(FieldAccess.java:112)


    Any idea what causes these failures?

    Regards

    Martin

  • 2. Re: Byte code limits?
    Martin Burger Newbie

     

    "mburger" wrote:
    I have similar problems, while instrumenting classes I get various exceptions:


    I just submitted an issue: http://jira.jboss.com/jira/browse/JASSIST-43

  • 3. Re: Byte code limits?
    Shigeru Chiba Expert

    Did you adjust the cursor of your ExprEditor subclass
    after inserting or deleting some bytecodes?

    The cursor might point to a wrong byte.

    (I submitted the same comment to JIRA)

  • 4. Re: Byte code limits?
    Martin Burger Newbie

     

    "chiba" wrote:
    (I submitted the same comment to JIRA)


    Thanks for your fast reply. I continued the thread in JIRA. I think that is the right place in order to document the issue.