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

ClassFormatException when instrumenting a Java 5 class

    Details

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

      Description

      Hi ,

      I am using BCEL to instrument Java classes of web applications in JDK1.6 ,1.5 .We encountered a ClassFormat exception for classes using Generics which prevented application from loading.From https://issues.apache.org/bugzilla/show_bug.cgi?id=33549 I saw a workaround to delete "LocalVariableTypeTable". I followed that suggestion and loop through the attributes and deleted attribute named "LocalVariableTypeTable". Still while loading the application I get a ClassFormatException.

      Example code in which I delete attribute "LocalvariableTypeTable" jc is JavaClass Object

              Method[] ma = jc.getMethods();
              for(int i = 0, x = ma.length; i < x; i++) {
                  try {
                      MethodGen mg = new MethodGen(ma[i],cg.getClassName(),cg.getConstantPool());
                      Attribute[] atts = mg.getCodeAttributes();
                      
                      for (int j = 0; j < atts.length; j++) {
                          if (atts[j].getNameIndex() == mg.getConstantPool().lookupUtf8("LocalVariableTypeTable")) {
                              mg.removeCodeAttribute(atts[j]);
                          }
                      }
                  } catch(Exception o1) {
                      output.write("exception " + o1);   
                  }
              }
      

      Also I get other error

      Caused by: java.lang.ClassFormatError: LVTT entry for 'patterns' in class file org/springframework/classname does not match any LVT entry
      

      and the application fails to load

        Attachments

          Activity

            People

            • Assignee:
              issues@commons.apache.org Apache Commons Developers
              Reporter:
              psramkumar@adventnet.com psramkumar
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: