]> source.dussan.org Git - javassist.git/commitdiff
Fixed a threading bug reported by JIRA Javassist-13
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Thu, 25 Aug 2005 09:52:35 +0000 (09:52 +0000)
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>
Thu, 25 Aug 2005 09:52:35 +0000 (09:52 +0000)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@197 30ef5769-5b8d-40dd-aea6-55b5d6557bb3

src/main/javassist/Loader.java

index ff8d4ced8f9c8824894ba8fc5232e61fb1c0495c..fe340510a3ecb4059f01639d54e4f0b6c90cac67 100644 (file)
@@ -284,20 +284,23 @@ public class Loader extends ClassLoader {
      */
     protected Class loadClass(String name, boolean resolve)
         throws ClassFormatError, ClassNotFoundException {
-        Class c = findLoadedClass(name);
-        if (c == null)
-            c = loadClassByDelegation(name);
+        name = name.intern();
+        synchronized (name) {
+            Class c = findLoadedClass(name);
+            if (c == null)
+                c = loadClassByDelegation(name);
 
-        if (c == null)
-            c = findClass(name);
+            if (c == null)
+                c = findClass(name);
 
-        if (c == null)
-            c = delegateToParent(name);
+            if (c == null)
+                c = delegateToParent(name);
 
-        if (resolve)
-            resolveClass(c);
+            if (resolve)
+                resolveClass(c);
 
-        return c;
+            return c;
+        }
     }
 
     /**