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

bcelified method doesn't pass verification

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 5.1
    • 6.0
    • Main
    • None
    • Operating System: Linux
      Platform: Other

    Description

      I bclified the following method:
      public String toString()

      { return ReflectionToStringBuilder.toString(this); }

      Which is the standard toString for bean as suggested by the commons-lang project.
      This code is generated:

      private void createMethod_7() {
      InstructionList il = new InstructionList();
      MethodGen method = new MethodGen(ACC_PUBLIC, Type.STRING, Type.NO_ARGS, new
      String[] { }, "toString",
      "it.imolinfo.iif.webservices.utils.generators.BCELifierSampleBean", il, _cp);

      InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0));

      il.append(_factory.createInvoke("org.apache.commons.lang.builder.ReflectionToStringBuilder",
      "toString", Type.STRING, new Type[]

      { Type.OBJECT }

      , Constants.INVOKESTATIC));
      InstructionHandle ih_4 = il.append(_factory.createReturn(Type.OBJECT));
      method.setMaxStack();
      method.setMaxLocals();
      _cg.addMethod(method.getMethod());
      il.dispose();
      }

      I'm reporting only the method that goes in error, in attachement there is the
      whole class.
      When I try to run the code and verify the class generated I get the following error:

      verify failed on step 3b on class:
      it.imolinfo.iif.webservices.utils.generators.BCELifierSampleBeanon method:
      toString message: Constraint violated in method 'public String toString()':
      Instruction INVOKESTATIC constraint violated: Class
      'org.apache.commons.lang.builder.ReflectionToStringBuilder' is referenced, but
      cannot be loaded and resolved: 'VERIFIED_REJECTED
      Number of LocalVariableTable attributes of Code attribute '<CODE>' (method
      'static void <clinit>()') exceeds number of local variable slots '0' ('There may
      be no more than one LocalVariableTable attribute per local variable in the Code
      attribute.').
      '.
      InstructionHandle: 1: invokestatic[184](3) 48

      Execution Frame:
      Local Variables:
      0: it.imolinfo.iif.webservices.utils.generators.BCELifierSampleBean
      OperandStack:
      Slots used: 1 MaxStack: 1.
      it.imolinfo.iif.webservices.utils.generators.BCELifierSampleBean (Size: 1)
      Execution flow:
      0: aload_0 [InstructionContext]
      1: invokestatic 48 [InstructionContext]
      at it.imolinfo.iif.jbi.BCELClassLoader.verifyClass(BCELClassLoader.java:66)
      at it.imolinfo.iif.jbi.BCELClassLoader.addClass(BCELClassLoader.java:27)
      at
      it.imolinfo.iif.test.webservices.utils.generators.BCELifierSampleBeanCreator.main(BCELifierSampleBeanCreator.java:260)

      Any idea if this is a bug or how to workaround it?
      Curiosly the twin method:

      public boolean equals(Object obj)

      { return EqualsBuilder.reflectionEquals(this, obj); }

      is generated passes the verification.

      Attachments

        1. BCELifierSampleBean.java
          2 kB
          Raffaele Spazzoli

        Activity

          People

            issues@commons.apache.org Apache Commons Developers
            raffaelespazzoli Raffaele Spazzoli
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: