diff options
author | aclement <aclement> | 2009-04-29 00:56:32 +0000 |
---|---|---|
committer | aclement <aclement> | 2009-04-29 00:56:32 +0000 |
commit | 4afa356104af67957a2353d0adaf8373f518b46d (patch) | |
tree | 2fd56529ac83a55737720c7597ccc0fc410fc3d7 /loadtime/src | |
parent | 5e8ba5a1320f80712cd9aabcdbd52af8ee92dd37 (diff) | |
download | aspectj-4afa356104af67957a2353d0adaf8373f518b46d.tar.gz aspectj-4afa356104af67957a2353d0adaf8373f518b46d.zip |
271840: deadlock in ltw with terracotta
Diffstat (limited to 'loadtime/src')
-rw-r--r-- | loadtime/src/org/aspectj/weaver/loadtime/Aj.java | 30 | ||||
-rw-r--r-- | loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java | 5 |
2 files changed, 18 insertions, 17 deletions
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. */ |