Locale.java (hashcode): No longer transient.

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.

From-SVN: r117248
This commit is contained in:
Tom Tromey 2006-09-27 07:58:11 +00:00 committed by Tom Tromey
parent 6ae7252263
commit d79d57fa02
2 changed files with 17 additions and 11 deletions

View File

@ -1,3 +1,11 @@
2006-09-27 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.
2006-09-25 Keith Seitz <keiths@redhat.com> 2006-09-25 Keith Seitz <keiths@redhat.com>
* gnu/classpath/jdwp/VMVirtualMachine.java * gnu/classpath/jdwp/VMVirtualMachine.java

View File

@ -1,5 +1,5 @@
/* Locale.java -- i18n locales /* 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. This file is part of GNU Classpath.
@ -190,7 +190,7 @@ public final class Locale implements Serializable, Cloneable
* *
* @serial should be -1 in serial streams * @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 * The default locale. Except for during bootstrapping, this should never be
@ -839,11 +839,9 @@ public final class Locale implements Serializable, Cloneable
private void writeObject(ObjectOutputStream s) private void writeObject(ObjectOutputStream s)
throws IOException throws IOException
{ {
s.writeObject(language); ObjectOutputStream.PutField fields = s.putFields();
s.writeObject(country); fields.put("hashcode", -1);
s.writeObject(variant); s.defaultWriteObject();
// Hashcode field is always written as -1.
s.writeInt(-1);
} }
/** /**
@ -857,10 +855,10 @@ public final class Locale implements Serializable, Cloneable
private void readObject(ObjectInputStream s) private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException throws IOException, ClassNotFoundException
{ {
language = ((String) s.readObject()).intern(); s.defaultReadObject();
country = ((String) s.readObject()).intern(); language = language.intern();
variant = ((String) s.readObject()).intern(); country = country.intern();
// Recompute hashcode. variant = variant.intern();
hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode(); hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
} }
} // class Locale } // class Locale