]> source.dussan.org Git - aspectj.git/commitdiff
fix for 120739
authormwebster <mwebster>
Thu, 1 Jun 2006 16:30:21 +0000 (16:30 +0000)
committermwebster <mwebster>
Thu, 1 Jun 2006 16:30:21 +0000 (16:30 +0000)
12 files changed:
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
tests/java5/ataspectj/ataspectj/EmptyAspect.aj [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/aop-dump.xml
tests/java5/ataspectj/ataspectj/aop-dumpbeforeandafter.xml
tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml
tests/java5/ataspectj/ataspectj/ltwreweavable/EmptyAtAspect.java [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml
tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml
tests/ltw/aop-optionsonly.xml [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
tests/src/org/aspectj/systemtest/ajc152/ajc152.xml

index 1cff6f2654cf7e039c3710bf4756e4cfc8ea4835..35277ba4d1b227c3d84e83658a44c000a7f932c4 100644 (file)
@@ -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 (file)
index 0000000..b22cf6f
--- /dev/null
@@ -0,0 +1,5 @@
+package ataspectj;
+
+public aspect EmptyAspect {
+       
+}
\ No newline at end of file
index 8290814ab3cdf8ee0b0e471bf1b538e65ee03ac2..9fd12bf915d4455d8954d620a2bddf9f13bc6cc1 100644 (file)
@@ -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>
index 43b74905300447e7e8b1694e9ab0e582c510e243..8f0ef772d3db055ac33cc653c142935b50eef3f2 100644 (file)
@@ -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..*"/>
index 1a76c01523e250994115c503e1f0a3fe1fb4eb8c..2c824579857e797d6ddd78579ca6f3b7f2604e93 100644 (file)
@@ -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 (file)
index 0000000..ee4caa1
--- /dev/null
@@ -0,0 +1,9 @@
+package ataspectj.ltwreweavable;
+
+import org.aspectj.lang.annotation.Aspect;
+
+@Aspect
+public class EmptyAtAspect {
+
+}
+    
\ No newline at end of file
index d89b5b3aafab4963d800d3a46d4b9ae711a626b8..a81c0bc7f4156a7a90a3f4aa0bb4a87ce54adac0 100644 (file)
@@ -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
index 4b53f2b1f972d537bea937a3d394e4bf6d6014de..869cd819e15177b23c5f169feb72cb747d6ff5b4 100644 (file)
@@ -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 (file)
index 0000000..408d8c4
--- /dev/null
@@ -0,0 +1,3 @@
+<aspectj>
+    <weaver options="-verbose"/>
+</aspectj>
index 4a0da8d3c77357fb98b5fcc7e07a25f67e4fb10c..23f0bfac1f46be1260f5a52020a94b7ec312883b 100644 (file)
@@ -87,6 +87,9 @@
     </ajc-test>
 
     <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"/>
@@ -94,6 +97,9 @@
     </ajc-test>
     
     <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"/>
                 <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>
     </ajc-test>
 
     <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"/>
 
     <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"/>
index 382a912cdadf4039ba7f65bc055f2a31e12c8392..78217bb526c7b6c8cede4e0a4ced429bfbf7f7ef 100644 (file)
@@ -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
 
index b8ff2b5860fd5512091433bf40362bee58b8b470..6ab18c57ed4678e75cb80ca12a41fc3686e21de3 100644 (file)
          <!-- 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