harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arc...@apache.org
Subject svn commit: r413558 - /incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/String.java
Date Mon, 12 Jun 2006 01:34:40 GMT
Author: archie
Date: Sun Jun 11 18:34:40 2006
New Revision: 413558

URL: http://svn.apache.org/viewvc?rev=413558&view=rev
Log:
Fix bug in r413349: the values in the WeakHashMap need to be weak too.

Modified:
    incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/String.java

Modified: incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/String.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/String.java?rev=413558&r1=413557&r2=413558&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/String.java
(original)
+++ incubator/harmony/enhanced/classlibadapter/trunk/modules/kernel/src/main/java/java/lang/String.java
Sun Jun 11 18:34:40 2006
@@ -74,13 +74,14 @@
 
 import java.io.Serializable;
 import java.io.UnsupportedEncodingException;
+import java.lang.ref.WeakReference;
 import java.nio.ByteBuffer;
 import java.nio.CharBuffer;
 import java.nio.charset.Charset;
 import java.util.Comparator;
 import java.util.Locale;
-import java.util.regex.Pattern;
 import java.util.WeakHashMap;
+import java.util.regex.Pattern;
 
 /**
  * @com.intel.drl.spec_ref 
@@ -1331,12 +1332,14 @@
 
     public String intern() {
         synchronized (internedStrings) {
-            String i = (String)internedStrings.get(this);
-            if (i == null) {
-		internedStrings.put(this, this);
-                i = this;
+            WeakReference ref = (WeakReference)internedStrings.get(this);
+            if (ref != null) {
+		String s = (String)ref.get();	// this could return null
+		if (s != null)
+		    return s;
             }
-            return i;
+	    internedStrings.put(this, new WeakReference(this));
+	    return this;
         }
     }
 }



Mime
View raw message