-
Bug
-
Resolution: Fixed
-
P3
-
8u65, 9
-
b137
-
x86_64
-
windows_7
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8255660 | openjdk8u282 | Zhengyu Gu | P3 | Resolved | Fixed | b01 |
JDK-8251229 | openjdk8u272 | Zhengyu Gu | P3 | Resolved | Fixed | b02 |
JDK-8241481 | 8u281 | Fairoz Matte | P3 | Resolved | Fixed | b01 |
JDK-8257272 | emb-8u281 | Fairoz Matte | P3 | Resolved | Fixed | team |
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
FULL OS VERSION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Constant pool entries of type "class" with class name "LClassName;" (without quotes) are interpreted by JVM as a reference to the class "ClassName".
Here is an excerpt from constant pool as reported by javap:
#15 = Utf8 LBadHelloWorld;
#16 = Class #15 // "LBadHelloWorld;"
The bytecode instruction
0: new #16 // class "LBadHelloWorld;"
will actually instantiate class with name "BadHelloWorld".
THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Yes
THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run generator class that will generate problematic *.class file.
See "Source code for an executable test case" field below for generator source.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
- Some kind of verification and/or runtime error, probably "NoClassDefFoundError".
Actual:
- Generated sample class file run without any visible problems.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
//
// !!! The ASM 5.x (http://asm.ow2.org/) library MUST be available in class path to compile and run the following code!
//
import java.util.*;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.objectweb.asm.*;
public class HelloWorldGen implements Opcodes {
public static String GENERATED_CLASS_NAME = "BadHelloWorld";
public static byte[] dump () throws Exception {
ClassWriter cw = new ClassWriter(0);
FieldVisitor fv;
MethodVisitor mv;
AnnotationVisitor av0;
cw.visit(52, ACC_PUBLIC + ACC_SUPER, GENERATED_CLASS_NAME, null, "java/lang/Object", null);
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null);
mv.visitCode();
mv.visitLdcInsn("Hello, world!");
mv.visitInsn(ARETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{
mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC + ACC_VARARGS, "main", "([Ljava/lang/String;)V", null, null);
mv.visitCode();
mv.visitTypeInsn(NEW, "L" + GENERATED_CLASS_NAME + ";");
mv.visitInsn(DUP);
mv.visitMethodInsn(INVOKESPECIAL, "L" + GENERATED_CLASS_NAME + ";", "<init>", "()V", false);
mv.visitVarInsn(ASTORE, 1);
mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/Object;)V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(2, 2);
mv.visitEnd();
}
cw.visitEnd();
return cw.toByteArray();
}
public static void main(String... args) throws Exception {
try (OutputStream out = Files.newOutputStream(Paths.get(GENERATED_CLASS_NAME + ".class"));) {
out.write(dump());
}
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8241481 Class names "SomeClass" and "LSomeClass;" treated by JVM as an equivalent
- Resolved
-
JDK-8251229 Class names "SomeClass" and "LSomeClass;" treated by JVM as an equivalent
- Resolved
-
JDK-8255660 Class names "SomeClass" and "LSomeClass;" treated by JVM as an equivalent
- Resolved
-
JDK-8257272 Class names "SomeClass" and "LSomeClass;" treated by JVM as an equivalent
- Resolved
- duplicates
-
JDK-8242352 openjdk1.8.0_232 did not report ClassFormatError when class name is illegal
- Closed
- relates to
-
JDK-8254937 Revert JDK-8148854 for 8u272
- Resolved
-
JDK-8341094 Clean up relax_verify in ClassFileParser
- Resolved
-
JDK-8263789 java.lang.ClassFormatError: Illegal field name "1" in class
- Open
-
JDK-8199585 A ClassFormatError, rather than a VerifyError
- Closed