I have tried both the release at http://people.apache.org/~tcurdt/bcel/rc2/ , as well as a build from head (410655). I see the same ClassFormatError with both. I get this error when running a JRat test case. This project and the test case is avalible on sourceforge (http://sourceforge.net/projects/jrat) - or I can provide it directly. The test case uses BCEL to isntrument a class and then tries to execute methods various methods on it. see org.shiftone.jrat.test.InjectorTestCase java.lang.ClassFormatError: LVTT entry for 'local' in class file org/shiftone/jrat/test/dummy/CrashTestDummy does not match any LVT entry at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.lang.ClassLoader.defineClass(ClassLoader.java:465) at org.shiftone.jrat.test.TestClassLoader.loadClass(TestClassLoader.java:36) at org.shiftone.jrat.test.InjectorTestCase.setUp(InjectorTestCase.java:52) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Compiling with -g:lines,source fixes the problem however this is not an acceptable option for me since a user may want to profile code that they didn't write or have the source for.
fair enough ...could you provide a patch? With some luck it could then still make it into 5.2
Changed the severity to "critical" because it renders BCEL useless on Java5 or newer.
What's the status here? Did you try with trunk? Would be great if you could attach the testcase.
Just tried with HEAD and does not work java.lang.ClassFormatError: LVTT entry for 'employees' in class file
The classes I'm using against trunk HEAD. Hope this helps class Department implements java.io.Serializable { private Collection<Employee> employees; public Collection<Employee> getEmployees() { return employees; } public void setEmployees(Collection<Employee> employees) { this.employees = employees; } } class Employee implements java.io.Serializable { private String name; }
Created attachment 19834 [details] copying the LVTT entries from method to MethodGen This patch fixes this issue to me. The fix is with copying the LVTT entries from method to MethodGen. In addition, a cosmetic change in the MethodGen.toString method to output the signature attributes, same as Method.toString does.
I forgot to say that the patch attached (2007-03-28 11:41), fix the case where a setter having a generic argument is bytecode modified using BCEL. I dont know if there are other cases. The patch works for me, for several classes and several scenarios. public void setEmployees(Collection<Employee> employees) { this.employees = employees; }
Thanks! Applied!