You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Jimmy, Jing Lv (JIRA)" <ji...@apache.org> on 2010/02/08 15:03:27 UTC

[jira] Resolved: (HARMONY-6439) NullPointerException thrown in certain Serialization cases

     [ https://issues.apache.org/jira/browse/HARMONY-6439?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jimmy, Jing Lv resolved HARMONY-6439.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 5.0M12

Code committed at 907657,  testcase at 907658, please verify.

> NullPointerException thrown in certain Serialization cases
> ----------------------------------------------------------
>
>                 Key: HARMONY-6439
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6439
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M12
>         Environment: Windows
>            Reporter: Charles Lamb
>            Assignee: Jimmy, Jing Lv
>            Priority: Minor
>             Fix For: 5.0M12
>
>         Attachments: ClassDescriptorOverrideBug.java
>
>
> Harmony object serialization has an initialization bug that causes NullPointerException when overriding the ObjectInputStream.readClassDescriptor and ObjectOutputStream.writeClassDescriptor methods, in order to store the ObjectStreamClass elsewhere.  In Berkeley DB, overriding these methods is necessary to store the ObjectStreamClass in a separate database, to avoid repeating it redundantly in every database record.  This type of overriding is supported by the Java specification, and the problem does not occur in other Java class libraries (specifically, the bug does not occur on the Sun, IBM and BEA Java platforms).
> The attached test demonstrates the problem by simply serializing and deserializing an object to/from a byte array, when readClassDescriptor and writeClassDescriptor are overridden.  A NullPointerException occurs because of an uninitialized field during the call to readObject.
> C:\temp>java -classpath . ClassDescriptorOverrideBug
> java.lang.NullPointerException
>         at java.io.ObjectStreamField.resolve(ObjectStreamField.java:336)
>         at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1838)
>         at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:799)
>         at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2039)
>         at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:902)
>         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2251)
>         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2208)
>         at ClassDescriptorOverrideBug.doTest(ClassDescriptorOverrideBug.java:49)
>         at ClassDescriptorOverrideBug.main(ClassDescriptorOverrideBug.java:29)
> Note that this problem only occurs when primitive fields are declared in the serializable class.
> A workaround for this bug is to serialize and deserialize the ObjectStreamClass before it is used.  Apparently deserialization causes initialization to occur correctly.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.