harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulex Yang (JIRA)" <j...@apache.org>
Subject [jira] Assigned: (HARMONY-969) java.util.TreeMap throws NotSerializableException
Date Tue, 25 Jul 2006 05:36:15 GMT
     [ http://issues.apache.org/jira/browse/HARMONY-969?page=all ]

Paulex Yang reassigned HARMONY-969:
-----------------------------------

    Assignee: Paulex Yang

> java.util.TreeMap throws NotSerializableException
> -------------------------------------------------
>
>                 Key: HARMONY-969
>                 URL: http://issues.apache.org/jira/browse/HARMONY-969
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Vasily Zakharov
>         Assigned To: Paulex Yang
>         Attachments: SerializationTreeMap.patch
>
>
> NotSerializableException occurs when trying to serialize a java.util.TreeMap object that
has entrySet() method called before.
> The cause for this is TreeMap class is serialized by defaultWriteObject(), and it contains
a non-transient field, entrySet, that is initialized in entrySet() method by an instance of
AbstractSet class that is not Serializable.
> Suggested fix: make entrySet field transient.
> Here's the code to reproduce the bug:
> import java.io.*;
> import java.util.*;
> public class SerializationTreeMapTest {
>     public static void main(String[] args) {
>         try {
>             TreeMap map = new TreeMap();
>             map.entrySet();
>             ByteArrayOutputStream bOut = new ByteArrayOutputStream();
>             ObjectOutputStream oOut = new ObjectOutputStream(bOut);
>             oOut.writeObject(map);
>             System.out.println("SUCCESS");
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
> and here's the output:
> C:\> java SerializationTreeMapTest
> java.io.NotSerializableException: java.util.TreeMap$1
>         at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1624)
>         at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1932)
>         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1768)
>         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1732)
>         at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1241)
>         at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:327)
>         at java.util.TreeMap.writeObject(TreeMap.java:1422)
>         at java.lang.reflect.VMReflection.invokeMethod(VMReflection.java)
>         at java.lang.reflect.Method.invoke(Method.java:183)
>         at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1318)
>         at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1658)
>         at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1932)
>         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1768)
>         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1732)
>         at SerializationTreeMapTest.main(SerializationTreeMapTest.java:11)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message