JDK-4800106 : VM regression in 1.4.2-b10: "illegal UTF8 string in constant pool"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.4.2
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2003-01-08
  • Updated: 2003-01-08
  • Resolved: 2003-01-08
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
This is a respin of #4793774, that was originally filed against 1.4.2-b10 javac and (incorrectly, IMO) closed as a duplicate of #4324508.

The problem seems to be that due to a stricter bytecode verification a code that was compiled with 1.3 javac may be no longer accepted by 1.4.2 VM. Although the tighter check may seem desirable, it may break existing applications built with previous releases of javac.

A copy of the original bug report by ###@###.### follows:
-------------------------------------------------------------------------------
Consider this source file, which is stripped out of:

http://cvs.apache.org/viewcvs.cgi/xml-xerces/java/src/org/apache/xerces/impl/xpath/regex/Token.java

----%<---- Test.java
public class Test {
    private static final String x1 = "\u0000\u007F\u0080\u00FF\u0100\u017F\u0180\u024F\u0250\u02AF\u02B0\u02FF\u0300\u036F\u0370\u03FF\u0400\u04FF\u0530\u058F\u0590\u05FF\u0600\u06FF\u0700\u074F\u0780\u07BF";
    public static void main(String[] args) {
        StringBuffer buf1 = new StringBuffer(String.valueOf(x1.length()));
        StringBuffer buf2 = new StringBuffer("OK; length=");
        buf2.append(buf1);
        System.out.println(buf2);
    }
}
----%<----

Compiled under 1.3.1, it can be run on 1.3.1 or 1.4.1_01 but not 1.4.2-beta-b10. Compiled under 1.4.x, it can be run on 1.4.x but not 1.3.1.

illegalutf8test$ /space/jdk1.3.1_03/bin/javac Test.java
illegalutf8test$ /space/jdk1.3.1_03/bin/java Test
OK; length=28
illegalutf8test$ /space/jdk1.4.1_01/bin/java Test
OK; length=28
illegalutf8test$ /space/jdk1.4.2-beta-b10/bin/java Test
Exception in thread "main" java.lang.ClassFormatError: Test (Illegal UTF8 string in constant pool)
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:504)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
Could not find the main class. Program will exit.
illegalutf8test$ /space/jdk1.4.1_01/bin/javac Test.java
illegalutf8test$ /space/jdk1.3.1_03/bin/java Test
Exception in thread "main" java.lang.NoSuchMethodError
	at Test.main(Test.java:6)
illegalutf8test$ /space/jdk1.4.1_01/bin/java Test
OK; length=28
illegalutf8test$ /space/jdk1.4.2-beta-b10/bin/java Test
OK; length=28
illegalutf8test$ /space/jdk1.4.2-beta-b10/bin/javac Test.java
illegalutf8test$ /space/jdk1.3.1_03/bin/java Test
Exception in thread "main" java.lang.NoSuchMethodError
	at Test.main(Test.java:6)
illegalutf8test$ /space/jdk1.4.1_01/bin/java Test
OK; length=28
illegalutf8test$ /space/jdk1.4.2-beta-b10/bin/java Test
OK; length=28
illegalutf8test$ /space/jdk1.3.1_03/bin/java -version
java version "1.3.1_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_03-b03)
Java HotSpot(TM) Client VM (build 1.3.1_03-b03, mixed mode)
illegalutf8test$ /space/jdk1.4.1_01/bin/java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
illegalutf8test$ /space/jdk1.4.2-beta-b10/bin/java -version
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b10)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b10, mixed mode)
illegalutf8test$ 


Looks like some check in the VM was tightened up in 1.4.2 - unfortunately this can break older compiled code.


To see in NetBeans, get a NetBeans development build, open an XML file, and right-click in the Editor and choose Validate XML. Under 1.4.1_01, it validates; under 1.4.2, a ClassFormatError is thrown from Xerces code. I do not know offhand what version of javac was used to compile this xerces2.jar; I think we got it in binary form from xml.apache.org.
###@###.### 2002-12-13

Comments
WORK AROUND None known.
11-06-2004