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

BCEL 5.2 - MethodGen does not initialize max_stack and max_locals properly

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: unspecified
    • Fix Version/s: None
    • Component/s: Main
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      The constructor for MethodGen:

      public MethodGen(Method, String, ConstantPoolGen)

      does not properly initialize the max_stack and max_local variables from the
      Method object. Thus the following sequence of actions will produce a
      non-verifying class, even though it clearly shouldn't:

      ClassGen cg = new ClassGen(javaClass);
      Method m = cg.getMethodAt(0);
      MethodGen mg = new MethodGen(m, cg.getClassName(), cg.getConstantPool());
      cg.setMethodAt(mg.getMethod(), 0);
      cg.getJavaClass().dump(...);

      Bug can be fixed by adding the following the constructor:

      Code c = m.getCode();
      max_stack = c.getMaxStack();
      max_locals = c.getMaxLocals();

        Attachments

          Activity

            People

            • Assignee:
              issues@commons.apache.org Apache Commons Developers
              Reporter:
              alkinneer@hotmail.com Alex Kinneer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: