URLClassLoader.java (addURLImpl): Reset 'thisString'.
authorTom Tromey <tromey@redhat.com>
Wed, 9 Mar 2005 20:10:18 +0000 (20:10 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Wed, 9 Mar 2005 20:10:18 +0000 (20:10 +0000)
* java/net/URLClassLoader.java (addURLImpl): Reset 'thisString'.
(toString): Synchronize.

From-SVN: r96205

libjava/ChangeLog
libjava/java/net/URLClassLoader.java

index d1a91d2be7107a77465863cc432cfe67c8749634..9d34f47adea080b3e808c132c5af0f7ae92d0d51 100644 (file)
@@ -1,3 +1,8 @@
+2005-03-09  Tom Tromey  <tromey@redhat.com>
+
+       * java/net/URLClassLoader.java (addURLImpl): Reset 'thisString'.
+       (toString): Synchronize.
+
 2005-03-08  Bryce McKinlay  <mckinlay@redhat.com>
 
        * testsuite/libjava.lang/pr13107_2.xfail: Remove xfail.
index 919fc9de0f61a0b211777121dc404243aa200647..9593e7d0fb051627b97332d53126f102c9dfcd27 100644 (file)
@@ -799,6 +799,9 @@ public class URLClassLoader extends SecureClassLoader
         if (newUrl == null)
           return; // Silently ignore...
 
+       // Reset the toString() value.
+       thisString = null;
+
         // Check global cache to see if there're already url loader
         // for this url.
         URLLoader loader = (URLLoader) urlloaders.get(newUrl);
@@ -1020,25 +1023,28 @@ public class URLClassLoader extends SecureClassLoader
    */
   public String toString()
   {
-    if (thisString == null)
+    synchronized (urlloaders)
       {
-       StringBuffer sb = new StringBuffer();
-       sb.append(this.getClass().getName());
-       sb.append("{urls=[" );
-       URL[] thisURLs = getURLs();
-       for (int i = 0; i < thisURLs.length; i++)
+       if (thisString == null)
          {
-           sb.append(thisURLs[i]);
-           if (i < thisURLs.length - 1)
-             sb.append(',');
+           StringBuffer sb = new StringBuffer();
+           sb.append(this.getClass().getName());
+           sb.append("{urls=[" );
+           URL[] thisURLs = getURLs();
+           for (int i = 0; i < thisURLs.length; i++)
+             {
+               sb.append(thisURLs[i]);
+               if (i < thisURLs.length - 1)
+                 sb.append(',');
+             }
+           sb.append(']');
+           sb.append(", parent=");
+           sb.append(getParent());
+           sb.append('}');
+           thisString = sb.toString();
          }
-       sb.append(']');
-       sb.append(", parent=");
-       sb.append(getParent());
-       sb.append('}');
-       thisString = sb.toString();
+       return thisString;
       }
-    return thisString;
   }
 
   /**