-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b04
-
generic
-
generic
SYNOPSIS
--------
Incompatible changes made to JDK 7 Serializable Swing classes
OPERATING SYSTEM
----------------
All
FULL JDK VERSION
----------------
JDK 7
PROBLEM DESCRIPTION from LICENSEE
---------------------------------
I'm not sure exactly when the changes occurred, but the serialized form of the following classes in recent JDK 7 builds are not compatible with prior versions of Java:
javax.swing.text.html.parser.ParserDelegator
javax.swing.LayoutComparator
These classes need to be modified such that their SUIDs match previous releases (if that is possible/appropriate), or they need to be declared as not compatible between releases in the API documentation, as is the case for some other serializable Swing classes. For example, the documentation for javax.swing.border.BevelBorder states:
Warning: Serialized objects of this class will not be compatible
with future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications
running the same version of Swing.
REPRODUCTION INSTRUCTIONS
-------------------------
Compile and run the attached testcase against the two classes highlighted above, on Java 6 and JDK 7. For example:
java GetSUID javax.swing.text.html.parser.ParserDelegator
2393192570582355838 (calculated)
The results for the two classes highlighted above are:
javax.swing.text.html.parser.ParserDelegator
Java 6 (6u24): 2393192570582355838
JDK 7 (b134): 1832828210669556215
javax.swing.LayoutComparator
Java 6 (6u24): -4870018609087598032
JDK 7 (b134): 8239258917856577386
TESTCASE
--------
import java.lang.reflect.*;
public class GetSUID {
public static void main (String args[]) throws Exception {
if (args.length != 1) {
System.out.println("Usage: java GetSUID [class name]");
System.exit(1);
}
// Get the target Class
Class targetClass = Class.forName(args[0]);
// Get the explicit SUID field (if it exists)
try {
Field suid = targetClass.getDeclaredField("serialVersionUID");
suid.setAccessible(true);
System.out.println(suid.getLong(null) + " (declared)");
System.exit(0);
} catch (NoSuchFieldException e) {
// SUID not declared. Catch Exception and move on...
}
// Get the computed SUID
Class oscClass = Class.forName("com.sun.corba.se.impl.io.ObjectStreamClass");
Method computeMethod = oscClass.getDeclaredMethod("_computeSerialVersionUID", new Class[] { Class.class });
computeMethod.setAccessible(true);
Long suid = (Long)computeMethod.invoke(null, new Object[] { targetClass });
System.out.println(suid.longValue() + " (calculated)");
}
}
Should this bug be p3? Perhaps this bug should be lowered according to Impact, liklihood and workaround guideline.
--------
Incompatible changes made to JDK 7 Serializable Swing classes
OPERATING SYSTEM
----------------
All
FULL JDK VERSION
----------------
JDK 7
PROBLEM DESCRIPTION from LICENSEE
---------------------------------
I'm not sure exactly when the changes occurred, but the serialized form of the following classes in recent JDK 7 builds are not compatible with prior versions of Java:
javax.swing.text.html.parser.ParserDelegator
javax.swing.LayoutComparator
These classes need to be modified such that their SUIDs match previous releases (if that is possible/appropriate), or they need to be declared as not compatible between releases in the API documentation, as is the case for some other serializable Swing classes. For example, the documentation for javax.swing.border.BevelBorder states:
Warning: Serialized objects of this class will not be compatible
with future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications
running the same version of Swing.
REPRODUCTION INSTRUCTIONS
-------------------------
Compile and run the attached testcase against the two classes highlighted above, on Java 6 and JDK 7. For example:
java GetSUID javax.swing.text.html.parser.ParserDelegator
2393192570582355838 (calculated)
The results for the two classes highlighted above are:
javax.swing.text.html.parser.ParserDelegator
Java 6 (6u24): 2393192570582355838
JDK 7 (b134): 1832828210669556215
javax.swing.LayoutComparator
Java 6 (6u24): -4870018609087598032
JDK 7 (b134): 8239258917856577386
TESTCASE
--------
import java.lang.reflect.*;
public class GetSUID {
public static void main (String args[]) throws Exception {
if (args.length != 1) {
System.out.println("Usage: java GetSUID [class name]");
System.exit(1);
}
// Get the target Class
Class targetClass = Class.forName(args[0]);
// Get the explicit SUID field (if it exists)
try {
Field suid = targetClass.getDeclaredField("serialVersionUID");
suid.setAccessible(true);
System.out.println(suid.getLong(null) + " (declared)");
System.exit(0);
} catch (NoSuchFieldException e) {
// SUID not declared. Catch Exception and move on...
}
// Get the computed SUID
Class oscClass = Class.forName("com.sun.corba.se.impl.io.ObjectStreamClass");
Method computeMethod = oscClass.getDeclaredMethod("_computeSerialVersionUID", new Class[] { Class.class });
computeMethod.setAccessible(true);
Long suid = (Long)computeMethod.invoke(null, new Object[] { targetClass });
System.out.println(suid.longValue() + " (calculated)");
}
}
Should this bug be p3? Perhaps this bug should be lowered according to Impact, liklihood and workaround guideline.
- csr for
-
JDK-8298431 JDK 7 Serializable Swing classes not compatible with JDK 6
-
- Closed
-