From 4513e921c89fb3b8f037418a901e49906724e7bd Mon Sep 17 00:00:00 2001 From: mwebster Date: Thu, 1 Jun 2006 16:30:21 +0000 Subject: [PATCH] fix for 120739 --- .../loadtime/ClassLoaderWeavingAdaptor.java | 20 +++++++++++++---- .../java5/ataspectj/ataspectj/EmptyAspect.aj | 5 +++++ tests/java5/ataspectj/ataspectj/aop-dump.xml | 3 +++ .../ataspectj/aop-dumpbeforeandafter.xml | 3 +++ .../ataspectj/ataspectj/aop-dumpproxy.xml | 3 +++ .../ltwreweavable/EmptyAtAspect.java | 9 ++++++++ .../aop-ltwreweavable-declared.xml | 1 + .../aop-ltwreweavable-omitted.xml | 4 +++- tests/ltw/aop-optionsonly.xml | 3 +++ .../systemtest/ajc150/ataspectj/ltw.xml | 12 +++++++++- .../systemtest/ajc152/Ajc152Tests.java | 6 ++++- .../org/aspectj/systemtest/ajc152/ajc152.xml | 22 +++++++++++++++++++ 12 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 tests/java5/ataspectj/ataspectj/EmptyAspect.aj create mode 100644 tests/java5/ataspectj/ataspectj/ltwreweavable/EmptyAtAspect.java create mode 100644 tests/ltw/aop-optionsonly.xml diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java index 1cff6f265..35277ba4d 100644 --- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java +++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java @@ -122,11 +122,17 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { // register the definitions registerDefinitions(weaver, loader, definitions); + if (enabled) { - //bcelWorld.setResolutionLoader(loader.getParent());//(ClassLoader)null);// - - // after adding aspects - weaver.prepareForWeave(); + //bcelWorld.setResolutionLoader(loader.getParent());//(ClassLoader)null);// + + // after adding aspects + weaver.prepareForWeave(); + } + else { + bcelWorld = null; + weaver = null; + } } /** @@ -368,6 +374,12 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor { } } } + + /* We didn't register any aspects so disable the adaptor */ + if (namespace == null) { + enabled = false; + info("no aspects registered. Disabling weaver for class loader " + getClassLoaderName(loader)); + } } /** diff --git a/tests/java5/ataspectj/ataspectj/EmptyAspect.aj b/tests/java5/ataspectj/ataspectj/EmptyAspect.aj new file mode 100644 index 000000000..b22cf6f76 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/EmptyAspect.aj @@ -0,0 +1,5 @@ +package ataspectj; + +public aspect EmptyAspect { + +} \ No newline at end of file diff --git a/tests/java5/ataspectj/ataspectj/aop-dump.xml b/tests/java5/ataspectj/ataspectj/aop-dump.xml index 8290814ab..9fd12bf91 100644 --- a/tests/java5/ataspectj/ataspectj/aop-dump.xml +++ b/tests/java5/ataspectj/ataspectj/aop-dump.xml @@ -1,5 +1,8 @@ + + + diff --git a/tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml b/tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml index 43b749053..8f0ef772d 100644 --- a/tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml +++ b/tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml @@ -1,5 +1,8 @@ + + + diff --git a/tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml b/tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml index 1a76c0152..2c8245798 100644 --- a/tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml +++ b/tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml @@ -1,5 +1,8 @@ + + + - + + + \ No newline at end of file diff --git a/tests/ltw/aop-optionsonly.xml b/tests/ltw/aop-optionsonly.xml new file mode 100644 index 000000000..408d8c4c7 --- /dev/null +++ b/tests/ltw/aop-optionsonly.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml index 4a0da8d3c..23f0bfac1 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml @@ -87,6 +87,9 @@ + @@ -94,6 +97,9 @@ + @@ -106,6 +112,7 @@ + @@ -119,6 +126,9 @@ + @@ -250,7 +260,7 @@ diff --git a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java index 382a912cd..78217bb52 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java @@ -15,7 +15,6 @@ import java.util.List; import junit.framework.Test; -//import org.aspectj.systemtest.ajc150.GenericsTests; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IHierarchy; import org.aspectj.asm.IProgramElement; @@ -133,6 +132,11 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // // public class Pair affected by pertarget aspect // GenericsTests.verifyClassSignature(ajc,"Pair","Ljava/lang/Object;LIdempotentCache$ajcMightHaveAspect;;"); // } + + public void testNoAspects(){ +// setSystemProperty(WeavingAdaptor.WEAVING_ADAPTOR_VERBOSE,"true"); + runTest("Ensure no weaving without included aspects"); + } // tests that can't be included for some reason diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml index b8ff2b586..6ab18c57e 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml @@ -607,5 +607,27 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file -- 2.39.5