[kaffe] CVS kaffe (dalibor): Resynced with GNU Classpath: Locale
Kaffe CVS
cvs-commits at kaffe.org
Sun Jul 11 22:27:48 PDT 2004
PatchSet 4951
Date: 2004/07/12 05:21:53
Author: dalibor
Branch: HEAD
Tag: (none)
Log:
Resynced with GNU Classpath: Locale
2004-07-11 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/java/util/Locale.java:
Resynced with GNU Classpath.
2004-07-05 Bryce McKinlay <mckinlay at redhat.com>
* java/util/Locale.java (readObject): Intern strings read from object
stream.
2004-07-05 Bryce McKinlay <mckinlay at redhat.com>
* java/util/Locale.java (hashcode): Made transient.
(hashCode): No longer synchronized.
(equals): Remove comment.
(writeObject): No longer synchronized. Implement using writeObject
calls instead of tweaking hashCode field. Update doc.
(readObject): Implement using readObject calls.
Members:
ChangeLog:1.2516->1.2517
libraries/javalib/java/util/Locale.java:1.15->1.16
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2516 kaffe/ChangeLog:1.2517
--- kaffe/ChangeLog:1.2516 Mon Jul 12 05:08:46 2004
+++ kaffe/ChangeLog Mon Jul 12 05:21:53 2004
@@ -14,6 +14,25 @@
2004-07-11 Dalibor Topic <robilad at kaffe.org>
+ * libraries/javalib/java/util/Locale.java:
+ Resynced with GNU Classpath.
+
+ 2004-07-05 Bryce McKinlay <mckinlay at redhat.com>
+
+ * java/util/Locale.java (readObject): Intern strings read from object
+ stream.
+
+ 2004-07-05 Bryce McKinlay <mckinlay at redhat.com>
+
+ * java/util/Locale.java (hashcode): Made transient.
+ (hashCode): No longer synchronized.
+ (equals): Remove comment.
+ (writeObject): No longer synchronized. Implement using writeObject
+ calls instead of tweaking hashCode field. Update doc.
+ (readObject): Implement using readObject calls.
+
+2004-07-11 Dalibor Topic <robilad at kaffe.org>
+
* libraries/javalib/java/text/DateFormat.java:
Resynced with GNU Classpath.
Index: kaffe/libraries/javalib/java/util/Locale.java
diff -u kaffe/libraries/javalib/java/util/Locale.java:1.15 kaffe/libraries/javalib/java/util/Locale.java:1.16
--- kaffe/libraries/javalib/java/util/Locale.java:1.15 Sun Mar 21 17:29:36 2004
+++ kaffe/libraries/javalib/java/util/Locale.java Mon Jul 12 05:21:55 2004
@@ -186,7 +186,7 @@
*
* @serial should be -1 in serial streams
*/
- private int hashcode;
+ private transient int hashcode;
/**
* The default locale. Except for during bootstrapping, this should never be
@@ -709,10 +709,8 @@
*
* @return the hashcode
*/
- public synchronized int hashCode()
+ public int hashCode()
{
- // This method is synchronized because writeObject() might reset
- // the hashcode.
return hashcode;
}
@@ -731,10 +729,6 @@
return false;
Locale l = (Locale) obj;
- // ??? We might also want to add:
- // hashCode() == l.hashCode()
- // But this is a synchronized method. Is the overhead worth it?
- // Measure this to make a decision.
return (language == l.language
&& country == l.country
&& variant == l.variant);
@@ -745,17 +739,19 @@
*
* @param output the stream to write to
* @throws IOException if the write fails
- * @serialData the hashcode should always be written as -1, and recomputed
- * when reading it back
+ * @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 synchronized void writeObject(ObjectOutputStream output)
+ private void writeObject(ObjectOutputStream s)
throws IOException
{
- // Synchronized so that hashCode() doesn't get wrong value.
- int tmpHashcode = hashcode;
- hashcode = -1;
- output.defaultWriteObject();
- hashcode = tmpHashcode;
+ s.writeObject(language);
+ s.writeObject(country);
+ s.writeObject(variant);
+ // Hashcode field is always written as -1.
+ s.writeInt(-1);
}
/**
@@ -766,10 +762,13 @@
* @throws ClassNotFoundException if reading fails
* @serialData the hashCode is always invalid and must be recomputed
*/
- private void readObject(ObjectInputStream input)
+ private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
- input.defaultReadObject();
+ language = ((String) s.readObject()).intern();
+ country = ((String) s.readObject()).intern();
+ variant = ((String) s.readObject()).intern();
+ // Recompute hashcode.
hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
}
} // class Locale
More information about the kaffe
mailing list