You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Oliver Deakin (JIRA)" <ji...@apache.org> on 2006/04/26 11:27:03 UTC

[jira] Updated: (HARMONY-187) java.io.ObjectOutputStream.writeUnshared() works incorrectly.

     [ http://issues.apache.org/jira/browse/HARMONY-187?page=all ]

Oliver Deakin updated HARMONY-187:
----------------------------------

    Attachment: writeUnshared.diff

Im attaching a proposed fix this bug. I found that writeUnshared was also functioning incorrectly when writing array objects (ie using Object o = new Object[1]; in the attached test). I have fixed this in the same patch.


> java.io.ObjectOutputStream.writeUnshared() works incorrectly.
> -------------------------------------------------------------
>
>          Key: HARMONY-187
>          URL: http://issues.apache.org/jira/browse/HARMONY-187
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Dmitry M. Kononov
>  Attachments: Test16.java, writeUnshared.diff
>
> Say, we write the same object by the following code:
> Object o = "foobar";
> oos.writeObject(o);
> oos.writeUnshared(o);
> oos.writeObject(o);
> And then, read the written data by the code as follows:
> Object[] oa = new Object[3];
> for (int i = 0; i < oa.length; i++) {
>     oa[i] = ois.readObject();
> }
> We expect that:
> 1) the 0th and 1st elements of the array are not equal. That is, oa[0] != oa[1].
> 2) the 1st and 2nd elements of the array are not equal. That is, oa[1] != oa[2].
> 3) the 0th and 2nd elements of the array are equal. That is, oa[0] == oa[2].
> All the three conditions are true if we run a test case in RI:
> oa[0] != oa[1] - true
> oa[1] != oa[2] - true
> oa[0] == oa[2] - true
> When we run the test case in Harmony the first condition is true and the rest two are false.
> oa[0] != oa[1] - true
> oa[1] != oa[2] - false
> oa[0] == oa[2] - false
> Here is an excerpt from the spec which shows us that Harmony behaves incorrectly:
> "If writeObject is used to write an object that has been previously written with writeUnshared, the previous writeUnshared operation is treated as if it were a write of a separate object. In other words, ObjectOutputStream will never generate back-references to object data written by calls to writeUnshared"
> Please note also, that oa[2] should be back-referenced to oa[0].
> I will attach the test case.

-- 
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