Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 75733 invoked from network); 29 Dec 2006 15:49:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Dec 2006 15:49:43 -0000 Received: (qmail 62936 invoked by uid 500); 29 Dec 2006 15:49:50 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 62840 invoked by uid 500); 29 Dec 2006 15:49:50 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 62828 invoked by uid 99); 29 Dec 2006 15:49:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Dec 2006 07:49:50 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Dec 2006 07:49:42 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 576A6714295 for ; Fri, 29 Dec 2006 07:49:22 -0800 (PST) Message-ID: <13989574.1167407362355.JavaMail.jira@brutus> Date: Fri, 29 Dec 2006 07:49:22 -0800 (PST) From: "Mikhail Markov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Updated: (HARMONY-1921) [classlib][luni] improper class replacement for the same base class names in ObjectInputStream.resolveClass() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ http://issues.apache.org/jira/browse/HARMONY-1921?page=all ] Mikhail Markov updated HARMONY-1921: ------------------------------------ Patch Info: [Patch Available] > [classlib][luni] improper class replacement for the same base class names in ObjectInputStream.resolveClass() > ------------------------------------------------------------------------------------------------------------- > > Key: HARMONY-1921 > URL: http://issues.apache.org/jira/browse/HARMONY-1921 > Project: Harmony > Issue Type: Bug > Components: Classlib > Environment: IA32, WinXP > Reporter: Mikhail Markov > Attachments: H-1921-impl.patch, H-1921-test.patch > > > Object serialization specification states that starting from JDK 1.6 method resolveClass in ObjectInputStream class could return a class with the same *base* class name (but, possibly from another package) and SerialVersionUID as the class provided for replacement. In this case the fields of replacement class should be initialized by the ones of original class from the stream. The following test passes on RI but fails on Harmony: > ------------------------- Test.java ----------------------------- > import java.io.*; > public class Test { > public static void main(String[] args) throws Exception { > a.TestClass to1 = new a.TestClass(); > to1.i = 555; > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > ObjectOutputStream oos = new ObjectOutputStream(baos); > oos.writeObject(to1); > oos.flush(); > byte[] bytes = baos.toByteArray(); > ByteArrayInputStream bais = new ByteArrayInputStream(bytes); > ObjectInputStream ois = new TestObjectInputStream(bais); > try { > b.TestClass to2 = (b.TestClass) ois.readObject(); > if (to2.i != to1.i) { > System.out.println("Test failed. Expected: " + to1.i + ", got: " + to2.i); > } else { > System.out.println("Test passed."); > } > } catch (InvalidClassException ice) { > System.out.println("Test failed with exception: " + ice); > } > } > static class TestObjectInputStream extends ObjectInputStream { > public TestObjectInputStream(InputStream in) throws IOException { > super(in); > } > > protected Class resolveClass(ObjectStreamClass desc) > throws IOException, ClassNotFoundException { > if (desc.getName().equals("a.TestClass")) { > return b.TestClass.class; > } > return super.resolveClass(desc); > } > } > } > ----------------------------------------------------------------- > ------------------------- a/TestClass.java ----------------------------- > package a; > import java.io.Serializable; > public class TestClass implements Serializable { > private static final long serialVersionUID = 11111L; > public int i = 0; > } > ----------------------------------------------------------------- > ------------------------- b/TestClass.java ----------------------------- > package b; > import java.io.Serializable; > public class TestClass implements Serializable { > private static final long serialVersionUID = 11111L; > public int i = 0; > } > ----------------------------------------------------------------- > Output on RI: > Test passed. > Output on Harmony: > Test failed. Expected: 555, got: 0 -- 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