diff options
author | Tom Tromey <tromey@redhat.com> | 2006-10-03 16:31:29 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2006-10-03 16:31:29 +0000 |
commit | a8c59a9dfd315b41b9154d14ab42566a1979c03f (patch) | |
tree | bdf73bb6a4935bf36f9e16889a0c1dc5e7cb4dcf | |
parent | c98f07b41429f3fd821c7f8736e4131d4312f77b (diff) | |
download | classpath-a8c59a9dfd315b41b9154d14ab42566a1979c03f.tar.gz |
* java/util/Locale.java (hashcode): Updated javadoc.
(hashcodeCache): Removed.
(Locale): Updated.
(hashCode): Updated.
(writeObject): New method.
(readObject): Updated.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | java/util/Locale.java | 36 |
2 files changed, 33 insertions, 12 deletions
@@ -1,3 +1,12 @@ +2006-10-03 Tom Tromey <tromey@redhat.com> + + * java/util/Locale.java (hashcode): Updated javadoc. + (hashcodeCache): Removed. + (Locale): Updated. + (hashCode): Updated. + (writeObject): New method. + (readObject): Updated. + 2006-10-02 Francis Kung <fkung@redhat.com> * gnu/java/awt/peer/gtk/BufferedImageGraphics.java diff --git a/java/util/Locale.java b/java/util/Locale.java index 001c7afde..4c91eeb0a 100644 --- a/java/util/Locale.java +++ b/java/util/Locale.java @@ -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. @@ -188,17 +188,11 @@ public final class Locale implements Serializable, Cloneable private String variant; /** - * This is where the JDK caches its hashcode. This is is only here - * for serialization purposes. The actual cache is hashcodeCache + * This is the cached hashcode. When writing to stream, we write -1. * * @serial should be -1 in serial streams */ - private int hashcode = -1; - - /** - * This is the cached hashcode. - */ - private transient int hashcodeCache; + private int hashcode; /** * Array storing all available locales. @@ -330,7 +324,7 @@ public final class Locale implements Serializable, Cloneable this.language = language; this.country = country; this.variant = variant; - hashcodeCache = language.hashCode() ^ country.hashCode() ^ variant.hashCode(); + hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode(); } /** @@ -905,7 +899,7 @@ public final class Locale implements Serializable, Cloneable */ public int hashCode() { - return hashcodeCache; + return hashcode; } /** @@ -929,6 +923,24 @@ public final class Locale implements Serializable, Cloneable } /** + * Write the locale to an object stream. + * + * @param s the stream to write to + * @throws IOException if the write fails + * @serialData The first three fields are Strings representing language, + * country, and variant. The fourth field is a placeholder for + * the cached hashcode, but this is always written as -1, and + * recomputed when reading it back. + */ + private void writeObject(ObjectOutputStream s) + throws IOException + { + ObjectOutputStream.PutField fields = s.putFields(); + fields.put("hashcode", -1); + s.defaultWriteObject(); + } + + /** * Reads a locale from the input stream. * * @param s the stream to read from @@ -943,6 +955,6 @@ public final class Locale implements Serializable, Cloneable language = language.intern(); country = country.intern(); variant = variant.intern(); - hashcodeCache = language.hashCode() ^ country.hashCode() ^ variant.hashCode(); + hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode(); } } // class Locale |