From: aclement Date: Wed, 29 Apr 2009 00:56:32 +0000 (+0000) Subject: 271840: deadlock in ltw with terracotta X-Git-Tag: V1_6_5~57 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4afa356104af67957a2353d0adaf8373f518b46d;p=aspectj.git 271840: deadlock in ltw with terracotta --- diff --git a/loadtime/src/org/aspectj/weaver/loadtime/Aj.java b/loadtime/src/org/aspectj/weaver/loadtime/Aj.java index 668622589..db5337e38 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/Aj.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/Aj.java @@ -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 diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index f821cb224..b4824c83c 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -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. */