https://issues.apache.org/bugzilla/show_bug.cgi?id=45217
Matthew Wilson <[EMAIL PROTECTED]> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|L |MethodGen: | |LocalVariableTableGen issues --- Comment #1 from Matthew Wilson <[EMAIL PROTECTED]> 2008-06-16 13:15:52 PST --- MethodGen mistakenly fills in LocalVariableTableGen from both LocalVariableTable and LocalVariableTypeTable. In parsing LocalVariableTypeTable, it incorrectly reads the signatures with generics. As a result, the LocalVariableTable is corrupted. Here is an example: public class VariableTableBug { public String getFirstItem( final List< String > list ) { int index = 0; String result = list.get( index ); return result; } public static void main( final String[] args ) throws Exception { // find the resource that is our class Class< VariableTableBug > clazz = VariableTableBug.class; String resource = clazz.getName().replace( '.', '/' ) + ".class"; // load it using BCEL JavaClass javaClass = new ClassParser( clazz.getClassLoader().getResourceAsStream( resource ), resource ).parse(); // convert everything to a ClassGen ClassGen classGen = new ClassGen( javaClass ); // find them getFirstItem method Method getFirstItemMethod = null; for ( Method method : classGen.getMethods() ) { if ( method.getName().equals( "getFirstItem" ) ) { getFirstItemMethod = method; break; } } // dump the LocalVariableTable attribute System.out.println( "LocalVariableTable of original" ); System.out.println( "------------------------------" ); for ( LocalVariable localVariable : getFirstItemMethod.getLocalVariableTable().getLocalVariableTable() ) { System.out.println( localVariable.getName() + "\t" + localVariable.getIndex() + "\t" + localVariable.getSignature() ); } System.out.println(); // dump the LocalVariableTypeTable attribute for ( Attribute attribute : getFirstItemMethod.getCode().getAttributes() ) { if ( attribute instanceof LocalVariableTypeTable ) { System.out.println( "LocalVariableTypeTable of original" ); System.out.println( "----------------------------------" ); for ( LocalVariable localVariable : ( (LocalVariableTypeTable) attribute ).getLocalVariableTypeTable() ) { System.out.println( localVariable.getName() + "\t" + localVariable.getIndex() + "\t" + localVariable.getSignature() ); } } } System.out.println(); // now convert to a MethodGen MethodGen methodGen = new MethodGen( getFirstItemMethod, classGen.getClassName(), classGen.getConstantPool() ); // dump the LocalVariableTable System.out.println( "LocalVariableTable of MethodGen" ); System.out.println( "-------------------------------" ); for ( LocalVariableGen localVariableGen : methodGen.getLocalVariables() ) { System.out.println( localVariableGen.getName() + "\t" + localVariableGen.getIndex() + "\t" + localVariableGen.getType() ); } } } -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]