JDK-6698652 : REG: serialization proccess throws NPE
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u10
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2008-05-07
  • Updated: 2012-03-22
  • Resolved: 2008-05-23
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 6 Other
6u10 b25Fixed OpenJDK6Resolved
Related Reports
Relates :  
Relates :  
Relates :  
Description
multiple JCK tests fails with NPE for 6u10 b23.

JCK            : JCK-runtime-6a b14
J2SE           : FAIL - jdk6u10 build 23
Platform[s]    : FAIL - Windows (XP prof., Vista, 2008) x86, solaris10 sparc
switch/Mode    : FAIL - any

List of test cases with stack traces:

api/java_awt/Dialog/serial/index.html#Input[serial2002]
java.lang.NullPointerException
        at java.util.Arrays$ArrayList.<init>(Arrays.java:3357)
        at java.util.Arrays.asList(Arrays.java:3343)
        at java.awt.Container.readObject(Container.java:3569)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at javasoft.sqe.serial.util.Convert.readObjectFromByteArray(Convert.java:120)
        at javasoft.sqe.serial.util.Convert.streamObjectToObject(Convert.java:53)
        at javasoft.sqe.tests.api.java.awt.Dialog.serial.InputTests.serial2002(InputTests.java:111)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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.Dialog.serial.InputTests.main(InputTests.java:33)
serial2002: Failed. Test case throws exception: java.lang.NullPointerException

api/java_awt/Event/serialization/descriptions.html#Events[testRead]
java.lang.NullPointerException
        at java.awt.Container.readObject(Container.java:3581)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        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:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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.Event.serialization.EventsTests.main(EventsTests.java:49)
testRead: Failed. Test case throws exception: java.lang.NullPointerException

api/java_awt/FileDialog/serial/index.html#Input[serial2002]
java.lang.NullPointerException
        at java.util.Arrays$ArrayList.<init>(Arrays.java:3357)
        at java.util.Arrays.asList(Arrays.java:3343)
        at java.awt.Container.readObject(Container.java:3569)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at javasoft.sqe.serial.util.Convert.readObjectFromByteArray(Convert.java:120)
        at javasoft.sqe.serial.util.Convert.streamObjectToObject(Convert.java:53)
        at javasoft.sqe.tests.api.java.awt.FileDialog.serial.InputTests.serial2002(InputTests.java:121)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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.FileDialog.serial.InputTests.main(InputTests.java:33)
serial2002: Failed. Test case throws exception: java.lang.NullPointerException

api/java_awt/Frame/serial/index.html#Input[serial2002]
java.lang.NullPointerException
        at java.util.Arrays$ArrayList.<init>(Arrays.java:3357)
        at java.util.Arrays.asList(Arrays.java:3343)
        at java.awt.Container.readObject(Container.java:3569)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at javasoft.sqe.serial.util.Convert.readObjectFromByteArray(Convert.java:120)
        at javasoft.sqe.serial.util.Convert.streamObjectToObject(Convert.java:53)
        at javasoft.sqe.tests.api.java.awt.Frame.serial.InputTests.serial2002(InputTests.java:159)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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.Frame.serial.InputTests.main(InputTests.java:33)
serial2002: Failed. Test case throws exception: java.lang.NullPointerException

api/java_awt/Panel/serial/index.html#Input[serial2002]
java.lang.NullPointerException
        at java.util.Arrays$ArrayList.<init>(Arrays.java:3357)
        at java.util.Arrays.asList(Arrays.java:3343)
        at java.awt.Container.readObject(Container.java:3569)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at javasoft.sqe.serial.util.Convert.readObjectFromByteArray(Convert.java:120)
        at javasoft.sqe.serial.util.Convert.streamObjectToObject(Convert.java:53)
        at javasoft.sqe.tests.api.java.awt.Panel.serial.InputTests.serial2002(InputTests.java:102)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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.Panel.serial.InputTests.main(InputTests.java:33)
serial2002: Failed. Test case throws exception: java.lang.NullPointerException

api/java_awt/ScrollPane/serial/index.html#Input[serial2002]
java.lang.NullPointerException
        at java.util.Arrays$ArrayList.<init>(Arrays.java:3357)
        at java.util.Arrays.asList(Arrays.java:3343)
        at java.awt.Container.readObject(Container.java:3569)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at javasoft.sqe.serial.util.Convert.readObjectFromByteArray(Convert.java:120)
        at javasoft.sqe.serial.util.Convert.streamObjectToObject(Convert.java:53)
        at javasoft.sqe.tests.api.java.awt.ScrollPane.serial.InputTests.serial2002(InputTests.java:130)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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.ScrollPane.serial.InputTests.main(InputTests.java:33)
serial2002: Failed. Test case throws exception: java.lang.NullPointerException

api/java_awt/Window/serial/index.html#Input[serial2002]
java.lang.NullPointerException
        at java.util.Arrays$ArrayList.<init>(Arrays.java:3357)
        at java.util.Arrays.asList(Arrays.java:3343)
        at java.awt.Container.readObject(Container.java:3569)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
        at javasoft.sqe.serial.util.Convert.readObjectFromByteArray(Convert.java:120)
        at javasoft.sqe.serial.util.Convert.streamObjectToObject(Convert.java:53)
        at javasoft.sqe.tests.api.java.awt.Window.serial.InputTests.serial2002(InputTests.java:139)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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.Window.serial.InputTests.main(InputTests.java:33)
serial2002: Failed. Test case throws exception: java.lang.NullPointerException

(see comments for more stack traces)

Comments
SUGGESTED FIX --- old/src/share/classes/java/awt/Container.java 2008-05-07 15:56:50.000000000 +0400 +++ new/src/share/classes/java/awt/Container.java 2008-05-07 15:56:50.000000000 +0400 @@ -3565,8 +3565,11 @@ { ObjectInputStream.GetField f = s.readFields(); Component [] tmpComponent = (Component[])f.get("component", EMPTY_ARRAY); - component = new java.util.ArrayList<Component>(); - component.addAll(Arrays.asList(tmpComponent)); + int ncomponents = (Integer) f.get("ncomponents", 0); + component = new java.util.ArrayList<Component>(ncomponents); + for (int i = 0; i < ncomponents; ++i) { + component.add(tmpComponent[i]); + } layoutMgr = (LayoutManager)f.get("layoutMgr", null); dispatcher = (LightweightDispatcher)f.get("dispatcher", null); // Old stream. Doesn't contain maxSize among Component's fields.
07-05-2008

EVALUATION problems are in the fiollowing code: Component [] tmpComponent = (Component[])f.get("component", EMPTY_ARRAY); component = new java.util.ArrayList<Component>(); component.addAll(Arrays.asList(tmpComponent)); sometimes we may have null as value of "component" field in the stream and we have NPE in Arrays.asList() Another problem is that tmpComponents may contain nulls (remove() may just set null to array and reduce ncomponents field). So, to fix the latter problem we should check value of ncomponents and add only first "ncomponents" elements. And the same change fixes the former problems because iftmpComponent is null, ncomponents == 0, and so we add nothing.
07-05-2008