-
Bug
-
Resolution: Duplicate
-
P2
-
None
-
5.0
-
generic
-
generic
When serializable anonymous inner class is used, VM throws java.lang.ClassFormatError.
Exception in thread "main" java.lang.ClassFormatError: Illegal class name "Test+1"
at sun.misc.Unsafe.defineClass(Native Method)
at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)
at sun.reflect.MethodAccessorGenerator+1.run(MethodAccessorGenerator.java:381)
at java.security.AccessController.doPrivileged(Native Method)
at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
at sun.reflect.MethodAccessorGenerator.generateSerializationConstructor(MethodAccessorGenerator.java:95)
at sun.reflect.ReflectionFactory.newConstructorForSerialization(ReflectionFactory.java:321)
at java.io.ObjectStreamClass.getSerializableConstructor(ObjectStreamClass.java:1310)
at java.io.ObjectStreamClass.access+1600(ObjectStreamClass.java:47)
at java.io.ObjectStreamClass+3.run(ObjectStreamClass.java:396)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:375)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:270)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1026)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1366)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1338)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1281)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1070)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
at Test.main(Test.java:15)
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)
This bug is introduced by the fix for 4884881 made in javac
Steps to reproduce:
1. Compile and run Test.java
2. Throws ClassFormatError.
===========================================================================
//Test.java
import java.io.*;
public class Test implements Serializable {
Serializable ser = new Serializable() {
};
public static void main(String[] args) {
Test test = new Test();
ObjectOutputStream stream = null;
try {
stream = new ObjectOutputStream(new FileOutputStream("temp"));
stream.writeObject(test);
stream.close();
} catch(IOException e) {
System.err.println("Couldn't write to temp : " + e);
}
System.out.println("Unexpected success");
}
}
=========================================================================
- duplicates
-
JDK-4972791 REGRESSION: 5 Regression-test tests fail with ClassFormatError
- Closed