United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8003147 : port fix for BCEL bug 39695 to our copy bundled as part of jaxp

Details
Type:
Bug
Submit Date:
2012-11-08
Status:
Resolved
Updated Date:
2013-06-22
Project Name:
JDK
Resolved Date:
2013-01-11
Component:
xml
OS:
Sub-Component:
jaxp
CPU:
Priority:
P3
Resolution:
Fixed
Affected Versions:
Fixed Versions:

Related Reports
Backport:
Backport:
Backport:
Backport:

Sub Tasks

Description
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 ]
https://issues.apache.org/bugzilla/show_bug.cgi?id=39695

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

    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")) {
                break;
            }
        }
        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"));
        Class.forName("NewTestCase");
    }

    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)
===

                                    

Comments
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jaxp/rev/47738fa4d411
User:  lana
Date:  2013-01-29 18:32:39 +0000

                                     
2013-01-29
URL:   http://hg.openjdk.java.net/jdk8/tl/jaxp/rev/47738fa4d411
User:  vikram
Date:  2013-01-11 05:10:17 +0000

                                     
2013-01-11
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).

                                     
2012-12-18



Hardware and Software, Engineered to Work Together