-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6u25
-
x86
-
linux
FULL PRODUCT VERSION :
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
This problem is OS independent.
A DESCRIPTION OF THE PROBLEM :
In 1.6.0_26 a new private method createNoPermsComponent() has been introduced into javax.swing.ImageIcon. That method is called from an anonymous inner class. Therefore the compiler has to insert a package-protected bridge method. This in turn changes the automatically calculated serial version UID for ImageIcon (which has been stable for the last decade) resulting in an InvalidClassException. Although ImageIcon explicitly states "The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing." serialization should not break between patch levels. Moreover, the createNoPermsComponent() is called only once; simply making createNoPermsComponent() a private method of the anonymous inner class should prevent this incompatiblity.
REGRESSION. Last worked in version 6
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Use the write method below to serialize an ImageIcon with JDK 1.6.0_25 or earlier.
2. Use the read method below to deserialize the previously serialized ImageIcon with JDK 1.6.0_26.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful serialization/deserialization (i.e. no exception).
ACTUAL -
Deserialization breaks with InvalidClassException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.io.InvalidClassException: javax.swing.ImageIcon; local class incompatible: stream classdesc serialVersionUID = 532615968316031794, local class serialVersionUID = -962022720109015502
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
void write( final String PATH ) {
final ImageIcon icon = new ImageIcon();
try {
System.out.println("Writing " + PATH + " using " + System.getProperty("java.version") + " ...");
final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(PATH));
try {
oos.writeObject(icon);
} finally {
oos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
void read( final String PATH ) {
try {
System.out.println("Reading " + PATH + " using " + System.getProperty("java.version") + " ...");
final ObjectInputStream ois = new ObjectInputStream(new FileInputStream(PATH));
try {
ois.readObject();
} finally {
ois.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
---------- END SOURCE ----------
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
This problem is OS independent.
A DESCRIPTION OF THE PROBLEM :
In 1.6.0_26 a new private method createNoPermsComponent() has been introduced into javax.swing.ImageIcon. That method is called from an anonymous inner class. Therefore the compiler has to insert a package-protected bridge method. This in turn changes the automatically calculated serial version UID for ImageIcon (which has been stable for the last decade) resulting in an InvalidClassException. Although ImageIcon explicitly states "The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing." serialization should not break between patch levels. Moreover, the createNoPermsComponent() is called only once; simply making createNoPermsComponent() a private method of the anonymous inner class should prevent this incompatiblity.
REGRESSION. Last worked in version 6
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Use the write method below to serialize an ImageIcon with JDK 1.6.0_25 or earlier.
2. Use the read method below to deserialize the previously serialized ImageIcon with JDK 1.6.0_26.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Successful serialization/deserialization (i.e. no exception).
ACTUAL -
Deserialization breaks with InvalidClassException.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.io.InvalidClassException: javax.swing.ImageIcon; local class incompatible: stream classdesc serialVersionUID = 532615968316031794, local class serialVersionUID = -962022720109015502
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1582)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
void write( final String PATH ) {
final ImageIcon icon = new ImageIcon();
try {
System.out.println("Writing " + PATH + " using " + System.getProperty("java.version") + " ...");
final ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(PATH));
try {
oos.writeObject(icon);
} finally {
oos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
void read( final String PATH ) {
try {
System.out.println("Reading " + PATH + " using " + System.getProperty("java.version") + " ...");
final ObjectInputStream ois = new ObjectInputStream(new FileInputStream(PATH));
try {
ois.readObject();
} finally {
ois.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-7059313 error with javax.swing.ImageIcon in 6.26? where programm compile with 6.24
-
- Closed
-