This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: fix Locale serialization
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 27 Sep 2006 01:51:00 -0600
- Subject: Patch: FYI: fix Locale serialization
- Reply-to: tromey at redhat dot com
I'm checking this in to trunk and the RH 4.1 branch.
This fixes a Locale serialization bug reported in RH bugzilla.
Anthony helpfully pointed out that this was fixed in Classspath CVS a
little while back. I prefer my patch, I'll probably push it back
upstream (Locale is still divergent...).
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=201712
* java/util/Locale.java (hashcode): No longer transient.
(writeObject): Use ObjectOutputStream.PutField and
defaultWriteObject.
(readObject): Use defaultReadObject.
Index: java/util/Locale.java
===================================================================
--- java/util/Locale.java (revision 117229)
+++ java/util/Locale.java (working copy)
@@ -1,5 +1,5 @@
/* Locale.java -- i18n locales
- Copyright (C) 1998, 1999, 2001, 2002, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2001, 2002, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -190,7 +190,7 @@
*
* @serial should be -1 in serial streams
*/
- private transient int hashcode;
+ private int hashcode;
/**
* The default locale. Except for during bootstrapping, this should never be
@@ -839,11 +839,9 @@
private void writeObject(ObjectOutputStream s)
throws IOException
{
- s.writeObject(language);
- s.writeObject(country);
- s.writeObject(variant);
- // Hashcode field is always written as -1.
- s.writeInt(-1);
+ ObjectOutputStream.PutField fields = s.putFields();
+ fields.put("hashcode", -1);
+ s.defaultWriteObject();
}
/**
@@ -857,10 +855,10 @@
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
- language = ((String) s.readObject()).intern();
- country = ((String) s.readObject()).intern();
- variant = ((String) s.readObject()).intern();
- // Recompute hashcode.
+ s.defaultReadObject();
+ language = language.intern();
+ country = country.intern();
+ variant = variant.intern();
hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
}
} // class Locale