]> source.dussan.org Git - aspectj.git/commitdiff
271840: deadlock in ltw with terracotta
authoraclement <aclement>
Wed, 29 Apr 2009 00:56:32 +0000 (00:56 +0000)
committeraclement <aclement>
Wed, 29 Apr 2009 00:56:32 +0000 (00:56 +0000)
loadtime/src/org/aspectj/weaver/loadtime/Aj.java
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java

index 6686225894265a475c228a7502c2f21c09bab1d9..db5337e384a96235b6dce678533059011e91d849 100644 (file)
@@ -63,6 +63,8 @@ public class Aj implements ClassPreProcessor {
 
        }
 
+       private final static String deleLoader = "sun.reflect.DelegatingClassLoader";
+
        /**
         * Weave
         * 
@@ -72,10 +74,9 @@ public class Aj implements ClassPreProcessor {
         * @return weaved bytes
         */
        public byte[] preProcess(String className, byte[] bytes, ClassLoader loader) {
-
                // TODO AV needs to doc that
-               if (loader == null || className == null) {
-                       // skip boot loader or null classes (hibernate)
+               if (loader == null || className == null || loader.getClass().getName().equals(deleLoader)) {
+                       // skip boot loader, null classes (hibernate), or those from a reflection loader
                        return bytes;
                }
 
@@ -220,6 +221,11 @@ public class Aj implements ClassPreProcessor {
                }
        }
 
+       static {
+               // pr271840 - touch the types early and outside the locks
+               new ExplicitlyInitializedClassLoaderWeavingAdaptor(new ClassLoaderWeavingAdaptor());
+       }
+
        /**
         * Cache of weaver There is one weaver per classloader
         */
@@ -231,21 +237,17 @@ public class Aj implements ClassPreProcessor {
                        ExplicitlyInitializedClassLoaderWeavingAdaptor adaptor = null;
                        AdaptorKey adaptorKey = new AdaptorKey(loader);
 
+                       String loaderClassName = loader.getClass().getName();
+
                        synchronized (weavingAdaptors) {
                                checkQ();
                                adaptor = (ExplicitlyInitializedClassLoaderWeavingAdaptor) weavingAdaptors.get(adaptorKey);
                                if (adaptor == null) {
-                                       String loaderClassName = loader.getClass().getName();
-                                       if (loaderClassName.equals("sun.reflect.DelegatingClassLoader")) {
-                                               // we don't weave reflection generated types at all!
-                                               return null;
-                                       } else {
-                                               // create it and put it back in the weavingAdaptors map but avoid any kind of instantiation
-                                               // within the synchronized block
-                                               ClassLoaderWeavingAdaptor weavingAdaptor = new ClassLoaderWeavingAdaptor();
-                                               adaptor = new ExplicitlyInitializedClassLoaderWeavingAdaptor(weavingAdaptor);
-                                               weavingAdaptors.put(adaptorKey, adaptor);
-                                       }
+                                       // create it and put it back in the weavingAdaptors map but avoid any kind of instantiation
+                                       // within the synchronized block
+                                       ClassLoaderWeavingAdaptor weavingAdaptor = new ClassLoaderWeavingAdaptor();
+                                       adaptor = new ExplicitlyInitializedClassLoaderWeavingAdaptor(weavingAdaptor);
+                                       weavingAdaptors.put(adaptorKey, adaptor);
                                }
                        }
                        // perform the initialization
index f821cb224a38db211b503964511cdc81370ece20..b4824c83cf74feca2a2bb5f99eec11170f0ddb69 100644 (file)
@@ -37,10 +37,10 @@ import org.aspectj.weaver.ResolvedType;
 import org.aspectj.weaver.UnresolvedType;
 import org.aspectj.weaver.World;
 import org.aspectj.weaver.Lint.Kind;
+import org.aspectj.weaver.bcel.BcelWeakClassLoaderReference;
 import org.aspectj.weaver.bcel.BcelWeaver;
 import org.aspectj.weaver.bcel.BcelWorld;
 import org.aspectj.weaver.bcel.Utility;
-import org.aspectj.weaver.bcel.BcelWeakClassLoaderReference;
 import org.aspectj.weaver.loadtime.definition.Definition;
 import org.aspectj.weaver.loadtime.definition.DocumentParser;
 import org.aspectj.weaver.ltw.LTWWorld;
@@ -741,12 +741,11 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
                        return super.getDumpDir();
                }
        }
-       
+
        /*
         * shared classes methods
         */
 
-
        /**
         * @return Returns the key.
         */