harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitry M. Kononov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-187) java.io.ObjectOutputStream.writeUnshared() works incorrectly.
Date Tue, 07 Mar 2006 13:27:39 GMT
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

Say, we write the same object by the following code:

Object o = "foobar";

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:
For more information on JIRA, see:

View raw message