Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 84072 invoked from network); 1 Mar 2007 13:30:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Mar 2007 13:30:13 -0000 Received: (qmail 73077 invoked by uid 500); 1 Mar 2007 13:30:22 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 73027 invoked by uid 500); 1 Mar 2007 13:30:22 -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 73009 invoked by uid 99); 1 Mar 2007 13:30:20 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Mar 2007 05:30:20 -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; Thu, 01 Mar 2007 05:30:11 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 5884C714296 for ; Thu, 1 Mar 2007 05:29:51 -0800 (PST) Message-ID: <26775847.1172755791360.JavaMail.jira@brutus> Date: Thu, 1 Mar 2007 05:29:51 -0800 (PST) From: "Alexei Zakharov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Closed: (HARMONY-3158) [classlib][luni]ObjectOutputStream.replaceObject fails when serializable object is Class or interface In-Reply-To: <14971830.1171271105947.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-3158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Alexei Zakharov closed HARMONY-3158. ------------------------------------ Was verified by Mikhail. Closed. > [classlib][luni]ObjectOutputStream.replaceObject fails when serializable object is Class or interface > ----------------------------------------------------------------------------------------------------- > > Key: HARMONY-3158 > URL: https://issues.apache.org/jira/browse/HARMONY-3158 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Igor V. Stolyarov > Assigned To: Alexei Zakharov > Attachments: H-3158.patch > > > ObjectOutputStream.replaceObject fails when serializable object is Class or interface > Test: > import java.net.*; > import java.io.*; > import java.util.*; > public class Test{ > > private static class ObjectOutputStreamWithReplace extends > ObjectOutputStream { > public ObjectOutputStreamWithReplace(OutputStream out) > throws IOException { > super(out); > enableReplaceObject(true); > } > protected Object replaceObject(Object obj) throws IOException { > if(obj instanceof Integer) obj = new Long(10); > return obj; > } > } > public static void main(String argv[]){ > try { > HashMap hm = new HashMap(); > hm.put("Long", new Integer(10)); > hm.put("Integer class", Integer.class); > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > ObjectOutputStream oos = new ObjectOutputStream(baos); > oos.writeObject(hm); > oos.flush(); > ObjectInputStream ois = new ObjectInputStream( > new ByteArrayInputStream(baos.toByteArray())); > > HashMap hm1 = (HashMap)ois.readObject(); > oos.close(); > ois.close(); > > Object obj = hm1.get("Long"); > if(obj instanceof Integer) System.out.println("Test part 1 - passed"); > else System.out.println("Test part 1 - failed"); > obj = hm1.get("Integer class"); > if(obj == Integer.class) System.out.println("Test part 2 - passed"); > else System.out.println("Test part 2 - failed"); > baos = new ByteArrayOutputStream(); > ObjectOutputStreamWithReplace ooswr = new ObjectOutputStreamWithReplace( > baos); > ooswr.writeObject(hm); > ooswr.flush(); > ois = new ObjectInputStream( > new ByteArrayInputStream(baos.toByteArray())); > > hm1 = (HashMap)ois.readObject(); > ooswr.close(); > ois.close(); > > obj = hm1.get("Long"); > if(obj instanceof Long) System.out.println("Test part 3 - passed"); > else System.out.println("Test part 3 - failed"); > obj = hm1.get("Integer class"); > if(obj == Integer.class) System.out.println("Test part 4 - passed"); > else System.out.println("Test part 4 - failed"); > } catch (Exception e) { > e.printStackTrace(); > } > } > } > ------------------------------------------------ > Output: > JRockit jdk: > java version "1.5.0" > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64) > BEA WebLogic JRockit(R) (build dra-38972-20041208-2001-win-ia32, R25.0.0-75, GC: > System optimized over throughput (initial strategy singleparpar)) > Test part 1 - passed > Test part 2 - passed > Test part 3 - passed > Test part 4 - passed > ------------------------------------------------------------- > Harmony: > Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundatio > n or its licensors, as applicable. > java version "1.5.0" > pre-alpha : not complete or compatible > svn = r504458, (Feb 7 2007), Windows/ia32/msvc 1310, release build > http://incubator.apache.org/harmony > Test part 1 - passed > Test part 2 - passed > Test part 3 - passed > Test part 4 - failed -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.