diff options
| author | Sven de Marothy <sven@physto.se> | 2006-08-13 00:20:10 +0000 |
|---|---|---|
| committer | Sven de Marothy <sven@physto.se> | 2006-08-13 00:20:10 +0000 |
| commit | f9d4ff6aa4c3d5f19b5a7f93c146bf1eee9549f7 (patch) | |
| tree | 9fa616b7ac3ed3147e398090d87804ed2b94dce3 /java | |
| parent | 04f3e82ec5a636855d68f80630d61355cf0560fb (diff) | |
| download | classpath-f9d4ff6aa4c3d5f19b5a7f93c146bf1eee9549f7.tar.gz | |
2006-08-13 Sven de Marothy <sven@physto.se>
* java/util/Locale.java
(hashcode): Is a serialized field, not transient.
(equals): Should NOT compare strings by reference.
(readObject/writeObject): Use the default methods and handle the hash
seperately.
Diffstat (limited to 'java')
| -rw-r--r-- | java/util/Locale.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/java/util/Locale.java b/java/util/Locale.java index d2aead43c..185e36ca1 100644 --- a/java/util/Locale.java +++ b/java/util/Locale.java @@ -192,7 +192,7 @@ public final class Locale implements Serializable, Cloneable * * @serial should be -1 in serial streams */ - private transient int hashcode; + private int hashcode; /** * Array storing all available locales. @@ -917,9 +917,9 @@ public final class Locale implements Serializable, Cloneable return false; Locale l = (Locale) obj; - return (language == l.language - && country == l.country - && variant == l.variant); + return (language.equals( l.language ) + && country.equals( l.country ) + && variant.equals( l.variant ) ); } /** @@ -935,11 +935,11 @@ public final class Locale implements Serializable, Cloneable 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); + int temp = hashcode; + hashcode = -1; + s.defaultWriteObject(); + hashcode = temp; } /** @@ -953,9 +953,7 @@ public final class Locale implements Serializable, Cloneable private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { - language = ((String) s.readObject()).intern(); - country = ((String) s.readObject()).intern(); - variant = ((String) s.readObject()).intern(); + s.defaultReadObject(); // Recompute hashcode. hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode(); } |
