Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 53616 invoked from network); 8 Feb 2010 13:32:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Feb 2010 13:32:51 -0000 Received: (qmail 17715 invoked by uid 500); 8 Feb 2010 13:32:51 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 17692 invoked by uid 500); 8 Feb 2010 13:32:51 -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 17683 invoked by uid 99); 8 Feb 2010 13:32:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Feb 2010 13:32:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Feb 2010 13:32:49 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id E4C8729A0011 for ; Mon, 8 Feb 2010 05:32:27 -0800 (PST) Message-ID: <1431610625.120681265635947935.JavaMail.jira@brutus.apache.org> Date: Mon, 8 Feb 2010 13:32:27 +0000 (UTC) From: "Jimmy, Jing Lv (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-6439) NullPointerException thrown in certain Serialization cases In-Reply-To: <317237251.67181265373447922.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-6439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12830937#action_12830937 ] Jimmy, Jing Lv commented on HARMONY-6439: ----------------------------------------- it is mainly caused by the Harmony ObjectStreamField does not resolve the primitive fields which are declared in the serializable correctly and miss-initialize the string type. A quick fix here is add 3 lines in the ObjectStreamField.resolve(ClassLoader loader): void resolve(ClassLoader loader) { + if (typeString == null && isPrimitive()){ + // primitive type declared in a serializable class + typeString = String.valueOf(getTypeCode()); + } if (typeString.length() == 1) { switch (typeString.charAt(0)) { case 'I': > NullPointerException thrown in certain Serialization cases > ---------------------------------------------------------- > > Key: HARMONY-6439 > URL: https://issues.apache.org/jira/browse/HARMONY-6439 > Project: Harmony > Issue Type: Bug > Components: Classlib > Affects Versions: 5.0M12 > Environment: Windows > Reporter: Charles Lamb > Assignee: Jimmy, Jing Lv > Priority: Minor > Attachments: ClassDescriptorOverrideBug.java > > > Harmony object serialization has an initialization bug that causes NullPointerException when overriding the ObjectInputStream.readClassDescriptor and ObjectOutputStream.writeClassDescriptor methods, in order to store the ObjectStreamClass elsewhere. In Berkeley DB, overriding these methods is necessary to store the ObjectStreamClass in a separate database, to avoid repeating it redundantly in every database record. This type of overriding is supported by the Java specification, and the problem does not occur in other Java class libraries (specifically, the bug does not occur on the Sun, IBM and BEA Java platforms). > The attached test demonstrates the problem by simply serializing and deserializing an object to/from a byte array, when readClassDescriptor and writeClassDescriptor are overridden. A NullPointerException occurs because of an uninitialized field during the call to readObject. > C:\temp>java -classpath . ClassDescriptorOverrideBug > java.lang.NullPointerException > at java.io.ObjectStreamField.resolve(ObjectStreamField.java:336) > at java.io.ObjectInputStream.readNewClassDesc(ObjectInputStream.java:1838) > at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:799) > at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:2039) > at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:902) > at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2251) > at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2208) > at ClassDescriptorOverrideBug.doTest(ClassDescriptorOverrideBug.java:49) > at ClassDescriptorOverrideBug.main(ClassDescriptorOverrideBug.java:29) > Note that this problem only occurs when primitive fields are declared in the serializable class. > A workaround for this bug is to serialize and deserialize the ObjectStreamClass before it is used. Apparently deserialization causes initialization to occur correctly. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.