This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: FYI: Locale: Intern strings from object stream
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Mon, 05 Jul 2004 18:35:39 -0400
- Subject: Patch: FYI: Locale: Intern strings from object stream
Locale relies on its strings being interned. When reading a locale from
serialized form, its possible that a non-interned string could end up in
the locale object. I'm checking this in.
Bryce
2004-07-05 Bryce McKinlay <mckinlay@redhat.com>
* java/util/Locale.java (readObject): Intern strings read from object
stream.
Index: java/util/Locale.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/Locale.java,v
retrieving revision 1.18
diff -u -r1.18 Locale.java
--- java/util/Locale.java 2 Jul 2004 19:41:32 -0000 1.18
+++ java/util/Locale.java 5 Jul 2004 22:32:41 -0000
@@ -765,9 +765,9 @@
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException
{
- language = (String) s.readObject();
- country = (String) s.readObject();
- variant = (String) s.readObject();
+ language = ((String) s.readObject()).intern();
+ country = ((String) s.readObject()).intern();
+ variant = ((String) s.readObject()).intern();
// Recompute hashcode.
hashcode = language.hashCode() ^ country.hashCode() ^ variant.hashCode();
}