Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 77003 invoked from network); 26 Apr 2006 09:28:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Apr 2006 09:28:16 -0000 Received: (qmail 92883 invoked by uid 500); 26 Apr 2006 09:27:26 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 92790 invoked by uid 500); 26 Apr 2006 09:27:25 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 92742 invoked by uid 99); 26 Apr 2006 09:27:25 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Apr 2006 02:27:25 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Apr 2006 02:27:24 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 40FB3410005 for ; Wed, 26 Apr 2006 09:27:03 +0000 (GMT) Message-ID: <38767919.1146043623236.JavaMail.root@brutus> Date: Wed, 26 Apr 2006 09:27:03 +0000 (GMT+00:00) From: "Oliver Deakin (JIRA)" To: harmony-commits@incubator.apache.org Subject: [jira] Updated: (HARMONY-187) java.io.ObjectOutputStream.writeUnshared() works incorrectly. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ 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