Uploaded image for project: 'Commons BCEL'
  1. Commons BCEL
  2. BCEL-66

Branch target offset too large for short

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Invalid
    • 5.1
    • None
    • Main
    • None
    • Operating System: Windows 2000
      Platform: Other

    Description

      We are using bcel library for code generation. And for some particualr scenarios
      our method size is exceeding the method size limit defined by java (65535 bytes)
      and we get the following error,

      org.apache.bcel.generic.ClassGenException: Branch target offset too large for short
      at org.apache.bcel.generic.BranchInstruction.dump(BranchInstruction.java:100)
      at org.apache.bcel.generic.InstructionList.getByteCode(InstructionList.java:980)
      at org.apache.bcel.generic.MethodGen.getMethod(MethodGen.java:616)
      When the method size limit is defined in java as 65535, why does the BCEL gives
      an error for 32767, in
      org.apache.bcel.generic.BranchInstruction.dump(DataOutputStream out) the check
      is for,

      if(Math.abs(index) >= 32767) // too large for short
      throw new ClassGenException("Branch target offset too large for short");

      why not instead have the if(Math.abs(index) >= 65535)

      I tried this and then my application works fine, I want to be sure if thats the
      right approach.

      Attachments

        Activity

          People

            issues@commons.apache.org Apache Commons Developers
            v_ssk@fareastone.com.tw JavaPursuit
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: