summaryrefslogtreecommitdiffstats
path: root/loadtime
diff options
context:
space:
mode:
authoravasseur <avasseur>2005-10-11 14:39:33 +0000
committeravasseur <avasseur>2005-10-11 14:39:33 +0000
commit3eda2272ac38529b540c99fc09b771f0581e6e73 (patch)
tree99da500802327d6abdb5d7e2af03354a03adf1f2 /loadtime
parent4286646e240114a5fc2010ece15960e206ba8006 (diff)
downloadaspectj-3eda2272ac38529b540c99fc09b771f0581e6e73.tar.gz
aspectj-3eda2272ac38529b540c99fc09b771f0581e6e73.zip
update for temp fix 99861 for Ron
Diffstat (limited to 'loadtime')
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/Aj.java56
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java6
2 files changed, 52 insertions, 10 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/Aj.java b/loadtime/src/org/aspectj/weaver/loadtime/Aj.java
index c340a2862..a34fdd2a1 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/Aj.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/Aj.java
@@ -52,7 +52,7 @@ public class Aj implements ClassPreProcessor {
* @param className
* @param bytes
* @param loader
- * @return
+ * @return weaved bytes
*/
public byte[] preProcess(String className, byte[] bytes, ClassLoader loader) {
//TODO AV needs to doc that
@@ -85,16 +85,54 @@ public class Aj implements ClassPreProcessor {
private static Map weavingAdaptors = new WeakHashMap();
static WeavingAdaptor getWeaver(ClassLoader loader, IWeavingContext weavingContext) {
- synchronized(loader) {//FIXME AV - temp fix for #99861
- synchronized (weavingAdaptors) {
- WeavingAdaptor weavingAdaptor = (WeavingAdaptor) weavingAdaptors.get(loader);
- if (weavingAdaptor == null) {
- weavingAdaptor = new ClassLoaderWeavingAdaptor(loader, weavingContext);
- weavingAdaptors.put(loader, weavingAdaptor);
- }
- return weavingAdaptor;
+ ExplicitlyInitializedClassLaoderWeavingAdaptor adaptor = null;
+ synchronized(weavingAdaptors) {
+ adaptor = (ExplicitlyInitializedClassLaoderWeavingAdaptor) weavingAdaptors.get(loader);
+ if (adaptor == null) {
+ // create it and put it back in the weavingAdaptors map but avoid any kind of instantiation
+ // within the synchronized block
+ ClassLoaderWeavingAdaptor weavingAdaptor = new ClassLoaderWeavingAdaptor(loader, weavingContext);
+ adaptor = new ExplicitlyInitializedClassLaoderWeavingAdaptor(weavingAdaptor);
+ weavingAdaptors.put(loader, adaptor);
}
}
+ // perform the initialization
+ return adaptor.getWeavingAdaptor(loader, weavingContext);
+
+
+ // old version
+// synchronized(loader) {//FIXME AV - temp fix for #99861
+// synchronized (weavingAdaptors) {
+// WeavingAdaptor weavingAdaptor = (WeavingAdaptor) weavingAdaptors.get(loader);
+// if (weavingAdaptor == null) {
+// weavingAdaptor = new ClassLoaderWeavingAdaptor(loader, weavingContext);
+// weavingAdaptors.put(loader, weavingAdaptor);
+// }
+// return weavingAdaptor;
+// }
+// }
+ }
+ }
+
+ static class ExplicitlyInitializedClassLaoderWeavingAdaptor {
+ private final ClassLoaderWeavingAdaptor weavingAdaptor;
+ private boolean isInitialized;
+
+ public ExplicitlyInitializedClassLaoderWeavingAdaptor(ClassLoaderWeavingAdaptor weavingAdaptor) {
+ this.weavingAdaptor = weavingAdaptor;
+ this.isInitialized = false;
+ }
+
+ private void initialize(ClassLoader loader, IWeavingContext weavingContext) {
+ if (!isInitialized) {
+ isInitialized = true;
+ weavingAdaptor.initialize(loader, weavingContext);
+ }
+ }
+
+ public ClassLoaderWeavingAdaptor getWeavingAdaptor(ClassLoader loader, IWeavingContext weavingContext) {
+ initialize(loader, weavingContext);
+ return weavingAdaptor;
}
}
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
index 7e1d9f05a..f314e19d5 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
@@ -58,7 +58,11 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
private IWeavingContext weavingContext;
public ClassLoaderWeavingAdaptor(final ClassLoader loader, IWeavingContext wContext) {
- super(null);// at this stage we don't have yet a generatedClassHandler to define to the VM the closures
+ super(null);
+ }
+
+ void initialize(final ClassLoader loader, IWeavingContext wContext) {
+ //super(null);// at this stage we don't have yet a generatedClassHandler to define to the VM the closures
this.generatedClassHandler = new GeneratedClassHandler() {
/**
* Callback when we need to define a Closure in the JVM