JDK-8003147 : port fix for BCEL bug 39695 to our copy bundled as part of jaxp
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2012-11-08
  • Updated: 2014-10-31
  • Resolved: 2013-01-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6 JDK 7 JDK 8
5.0u45Fixed 6u60Fixed 7u40Fixed 8 b75Fixed
Related Reports
Relates :  
The following issue impacts the copy of BCEL included with our copy of jaxp. This bug report is to include the fix for this issue into the JDK.

[ Bug 39695 - java.lang.ClassFormatError: LVTT entry for 'local' in class file org/shiftone/jrat/test/dummy/CrashTestDummy does not match any LVT entry ]

Simple test case:
=== TestCase.java
import com.sun.org.apache.bcel.internal.classfile.ClassParser;
import com.sun.org.apache.bcel.internal.classfile.ConstantClass;
import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
import com.sun.org.apache.bcel.internal.classfile.JavaClass;
import com.sun.org.apache.bcel.internal.classfile.Method;
import com.sun.org.apache.bcel.internal.generic.ClassGen;
import com.sun.org.apache.bcel.internal.generic.MethodGen;

import java.util.ArrayList;
import java.io.FileOutputStream;

class TestCase {
    public static void main(String[] args) throws Exception {

    private static void transform() throws Exception {
        JavaClass jc = new ClassParser("TestCase.class").parse();
        //rename class
        ConstantPool cp = jc.getConstantPool();
        int cpIndex = ((ConstantClass)cp.getConstant(jc.getClassNameIndex())).getNameIndex();
        cp.setConstant(cpIndex, new ConstantUtf8("NewTestCase"));
        ClassGen gen = new ClassGen(jc);
        Method[] methods = jc.getMethods();
        int index;
        for (index = 0; index < methods.length; index++) {
            if (methods[index].getName().equals("doSomething")) {
        Method m = methods[index];
        MethodGen mg = new MethodGen(m, gen.getClassName(), gen.getConstantPool());
        gen.replaceMethod(m, mg.getMethod());
        gen.getJavaClass().dump(new FileOutputStream("NewTestCase.class"));

    public void doSomething(double d, ArrayList<Integer> list) {

Example run:

$ javac -g TestCase.java
< ... warning about using an internal API removed >
$ java TestCase
Exception in thread "main" java.lang.ClassFormatError: LVTT entry for 'list' in class file NewTestCase does not match any LVT entry
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at TestCase.transform(TestCase.java:36)
        at TestCase.main(TestCase.java:15)

This fix needs to include porting support for LocalVariableTypeTable code attribute. This was supposed to be included with the fix 6271793 but that fix ended up only being an upgrade to BCEL 5.1 (which was too early to pick up support for LocalVariableTypeTable).