[ 
https://issues.apache.org/jira/browse/BCEL-129?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Emmanuel Bourg updated BCEL-129:
--------------------------------

    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
{code}
        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);   
            }
        }
{code}

Also I get other error

{code}
Caused by: java.lang.ClassFormatError: LVTT entry for 'patterns' in class file 
org/springframework/classname does not match any LVT entry
{code}
and the application fails to load


  was:
Hi ,
I am using Bcel to instrument java classes  of webapplications in JDK1.6 ,1.5 
.We encountered 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 
application I get 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 application fails to load

       Priority: Major
    Environment:     (was: Operating System: Windows XP
Platform: PC)
        Summary: ClassFormatException when instrumenting a Java 5 class  (was: 
problem using bcel in jdk15)

> ClassFormatException when instrumenting a Java 5 class
> ------------------------------------------------------
>
>                 Key: BCEL-129
>                 URL: https://issues.apache.org/jira/browse/BCEL-129
>             Project: Commons BCEL
>          Issue Type: Bug
>          Components: Main
>    Affects Versions: unspecified
>            Reporter: psramkumar
>            Assignee: Apache Commons Developers
>
> 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
> {code}
>         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);   
>             }
>         }
> {code}
> Also I get other error
> {code}
> Caused by: java.lang.ClassFormatError: LVTT entry for 'patterns' in class 
> file org/springframework/classname does not match any LVT entry
> {code}
> and the application fails to load



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to