JDK-6701268 : java.awt.Component can't work normally after deserialization
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u10,7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-05-13
  • Updated: 2012-03-22
  • Resolved: 2009-11-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b27Fixed
Related Reports
Relates :  
Relates :  
Description
JCK            : JCK-runtime-6b b24
J2SE           : FAIL - jdk6u10 build 23, jdk 7 b26
Platform[s]    : FAIL - All
switch/Mode    : FAIL - any

Changes in java.awt.Component near line 635:

    private transient final Object changeSupportLock = new Object();
    private Object getChangeSupportLock() {
        return changeSupportLock;
    }

cause every call to synchronized (getChangeSupportLock()) for deserialized component to throw NPE, since changeSupportLock is transient and null for deserialized object.

Affected JCK 6b tests:

api/java_awt/serialization/descriptions.html#Component[testRead]
api/java_awt/serialization/descriptions.html#Container[testRead]
api/java_awt/serialization/descriptions.html#TextArea[testRead]
api/java_awt/serialization/descriptions.html#TextComponent[testRead]



Tests report:

java.lang.NullPointerException
	at java.awt.Component.firePropertyChange(Component.java:8011)
	at java.awt.Component.setFocusTraversalKeys_NoIDCheck(Component.java:6895)
	at java.awt.Component.setFocusTraversalKeys(Component.java:6807)
	at java.awt.TextArea.readObject(TextArea.java:655)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:623)
	at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:991)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1866)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
	at javasoft.sqe.javatest.lib.SerializeTest.read(SerializeTest.java:413)
	at javasoft.sqe.javatest.lib.SerializeTest.testRead(SerializeTest.java:308)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:623)
	at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:406)
	at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195)
	at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:127)
	at javasoft.sqe.tests.api.java.awt.serialization.ComponentTests.main(ComponentTests.java:256)
testRead: Failed. Test case throws exception: java.lang.NullPointerException

Comments
EVALUATION This problem is resolved in JDK 6u10-b25 with the fix for 6698652.
29-05-2008

EVALUATION I've verified that there is a lack of the changeSupportLock field initialization while readObject() in JDK7b25. But NPE is not reproducible in latest JDK7 build (not yet promoted) because we alredy have following init: private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { changeSupportLock = new Object(); ...
19-05-2008

EVALUATION Confirm the test fails with JDK7b25. We don't restore the value of that field up to latest version of the JDK. I don't see the usage of changeSupportLock field in JDK6uN.
19-05-2008