aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormwebster <mwebster>2006-06-01 16:30:21 +0000
committermwebster <mwebster>2006-06-01 16:30:21 +0000
commit4513e921c89fb3b8f037418a901e49906724e7bd (patch)
tree8c97c62a5d57f1041326b8e37beb80c59f65f8b9
parenta5b31830511167ea4a8b9d750c7e1d16292e0938 (diff)
downloadaspectj-4513e921c89fb3b8f037418a901e49906724e7bd.tar.gz
aspectj-4513e921c89fb3b8f037418a901e49906724e7bd.zip
fix for 120739
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java20
-rw-r--r--tests/java5/ataspectj/ataspectj/EmptyAspect.aj5
-rw-r--r--tests/java5/ataspectj/ataspectj/aop-dump.xml3
-rw-r--r--tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml3
-rw-r--r--tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml3
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwreweavable/EmptyAtAspect.java9
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml1
-rw-r--r--tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml4
-rw-r--r--tests/ltw/aop-optionsonly.xml3
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml12
-rw-r--r--tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java6
-rw-r--r--tests/src/org/aspectj/systemtest/ajc152/ajc152.xml22
12 files changed, 84 insertions, 7 deletions
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 @@
<?xml version="1.0"?>
<aspectj>
+ <aspects>
+ <aspect name="ataspectj.EmptyAspect"/>
+ </aspects>
<weaver options="-XmessageHandlerClass:ataspectj.TestHelper">
<dump within="ataspectj.DumpTestThe*"/>
</weaver>
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 @@
<?xml version="1.0"?>
<aspectj>
+ <aspects>
+ <aspect name="ataspectj.EmptyAspect"/>
+ </aspects>
<weaver options="-XlazyTjp -verbose">
<dump within="com.foo.bar..*" beforeandafter="true"/>
<include within="com.foo..*"/>
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 @@
<?xml version="1.0"?>
<aspectj>
+ <aspects>
+ <aspect name="ataspectj.EmptyAspect"/>
+ </aspects>
<weaver>
<!--
<dump within="*..*Proxy*" beforeandafter="true"/>
diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/EmptyAtAspect.java b/tests/java5/ataspectj/ataspectj/ltwreweavable/EmptyAtAspect.java
new file mode 100644
index 000000000..ee4caa11e
--- /dev/null
+++ b/tests/java5/ataspectj/ataspectj/ltwreweavable/EmptyAtAspect.java
@@ -0,0 +1,9 @@
+package ataspectj.ltwreweavable;
+
+import org.aspectj.lang.annotation.Aspect;
+
+@Aspect
+public class EmptyAtAspect {
+
+}
+ \ No newline at end of file
diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml b/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml
index d89b5b3aa..a81c0bc7f 100644
--- a/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml
+++ b/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml
@@ -2,5 +2,6 @@
<weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/>
<aspects>
<aspect name="ataspectj.ltwreweavable.AspectReweavableLogging"/>
+ <aspect name="ataspectj.ltwreweavable.EmptyAtAspect"/>
</aspects>
</aspectj> \ No newline at end of file
diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml b/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml
index 4b53f2b1f..869cd819e 100644
--- a/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml
+++ b/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml
@@ -1,5 +1,7 @@
<aspectj>
<weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/>
<!--aspect is not declared here so as to produce an error -->
- <aspects/>
+ <aspects>
+ <aspect name="ataspectj.ltwreweavable.EmptyAtAspect"/>
+ </aspects>
</aspectj> \ 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 @@
+<aspectj>
+ <weaver options="-verbose"/>
+</aspectj>
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
@@ -88,6 +88,9 @@
<ajc-test dir="java5/ataspectj" title="LTW DumpTest">
<compile
+ files="ataspectj/EmptyAspect.aj"
+ options="-1.5 -Xlint:ignore"/>
+ <compile
files="ataspectj/DumpTest.java,ataspectj/DumpTestTheDump.java,ataspectj/TestHelper.java"
options="-1.5"/>
<run class="ataspectj.DumpTest" ltw="ataspectj/aop-dump.xml"/>
@@ -95,6 +98,9 @@
<ajc-test dir="java5/ataspectj" title="LTW DumpTest before and after">
<compile
+ files="ataspectj/EmptyAspect.aj"
+ options="-1.5 -Xlint:ignore"/>
+ <compile
files="com/foo/bar/Test.java, com/foo/bar/Test$$EnhancerByCGLIB$$12345.java"
options="-1.5"/>
<run class="com.foo.bar.Test$$EnhancerByCGLIB$$12345" ltw="ataspectj/aop-dumpbeforeandafter.xml">
@@ -106,6 +112,7 @@
<line text="info AspectJ Weaver Version"/>
<line text="info register classloader"/>
<line text="info using"/>
+ <line text="info register aspect ataspectj.EmptyAspect"/>
<line text="info weaving 'com.foo.bar.Test'"/>
</stderr>
</run>
@@ -120,6 +127,9 @@
<ajc-test dir="java5/ataspectj" title="LTW DumpTest proxy">
<compile
+ files="ataspectj/EmptyAspect.aj"
+ options="-1.5 -Xlint:ignore"/>
+ <compile
files="ataspectj/TestProxyGenerator.java,ataspectj/TestInterface.java"
options="-1.5"/>
<ant file="ajc-ant.xml" target="ltw.DumpProxyTest" verbose="true"/>
@@ -250,7 +260,7 @@
<ajc-test dir="java5/ataspectj" title="Compile time aspects declared to ltw weaver">
<compile
- files="ataspectj/ltwlog/MessageHolder.java,ataspectj/ltwreweavable/MainReweavableLogging.java,ataspectj/ltwreweavable/AspectReweavableLogging.java,ataspectj/ltwreweavable/Advisable.java"
+ files="ataspectj/ltwlog/MessageHolder.java,ataspectj/ltwreweavable/MainReweavableLogging.java,ataspectj/ltwreweavable/AspectReweavableLogging.java,ataspectj/ltwreweavable/Advisable.java,ataspectj/ltwreweavable/EmptyAtAspect.java"
options="-1.5"
outjar="main1.jar"/>
<ant file="ajc-ant.xml" target="ltw.oldAspectsDeclared" verbose="true"/>
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<F,S> affected by pertarget aspect
// GenericsTests.verifyClassSignature(ajc,"Pair","<F:Ljava/lang/Object;S:Ljava/lang/Object;>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 @@
<!-- should check for expected stderr output here -->
</run>
</ajc-test>
+
+ <ajc-test dir="ltw"
+ title="Ensure no weaving without included aspects"
+ keywords="reweavable">
+ <compile
+ files="TestMain.java, Main.java"
+ >
+ </compile>
+ <run class="TestMain" ltw="aop-optionsonly.xml">
+ <stdout>
+ <line text="Main.main"/>
+ <line text="Main.test1"/>
+ <line text="Main.test2"/>
+ </stdout>
+ <stderr>
+ <line text="info AspectJ Weaver Version"/>
+ <line text="info register classloader org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
+ <line text="info using"/>
+ <line text="info no aspects registered. Disabling weaver for class loader org.aspectj.weaver.loadtime.WeavingURLClassLoader"/>
+ </stderr>
+ </run>
+ </ajc-test>
</suite> \ No newline at end of file