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

FieldInstruction.getFieldSize() doesn't decode Type.getTypeSize() output

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: unspecified
    • Fix Version/s: 6.0
    • Component/s: Main
    • Labels:
      None

      Description

      The method getTypeSize(String) in the Type class returns two outputs encoded in one integer: the lowest two bits contain the field size (0, 1 or 2), the remaining ones the no. of consumed characters in the signature. Type provides two private static methods, size() and consumed(), to split these values apart.

      The method getFieldSize(ConstantPoolGen) in the FieldInstrucion class uses Type.getTypeSize, unaware that the output is encoded. Therefore, the returned size is different than expected. This causes, among other things, a bigger or smaller max stack depth value for generated methods that leads to unused stack memory or a "java.lang.VerifyError: stack size too large" exception, respectively.

      A fix can be made by making the above-mentioned static methods package-visible and modifying getFieldSize() to use them.

        Attachments

        1. patch.txt
          1 kB
          Enrico Gueli

          Activity

            People

            • Assignee:
              issues@commons.apache.org Apache Commons Developers
              Reporter:
              enrico.gueli@polito.it Enrico Gueli
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: