]> source.dussan.org Git - aspectj.git/commitdiff
fix issue in test for -1.5 and @AJ ITD with @anno
authoravasseur <avasseur>
Fri, 21 Oct 2005 16:08:10 +0000 (16:08 +0000)
committeravasseur <avasseur>
Fri, 21 Oct 2005 16:08:10 +0000 (16:08 +0000)
impl error message for reweavable and not declared in aop.xml as per David Knibb patch, #104218

12 files changed:
tests/java5/ataspectj/ajc-ant.xml
tests/java5/ataspectj/ataspectj/aop-decptest.xml
tests/java5/ataspectj/ataspectj/ltwreweavable/AspectReweavableLogging.java [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/ltwreweavable/MainReweavableLogging.java [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml [new file with mode: 0644]
tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
tests/src/org/aspectj/systemtest/ajc150/ataspectj/ltw.xml
weaver/src/org/aspectj/weaver/WeaverMessages.java
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/org/aspectj/weaver/weaver-messages.properties

index 6659b3f69d35a1bf157e8b3ad122fedaa0dc92bf..077fc2667c96d5adf3f912d8976e30a2cc3a62d8 100644 (file)
             debug="true">
             <classpath>
                 <path refid="aj.path"/>
-                <pathelement path="${aj.sandbox}"/>
             </classpath>
         </javac>
 
             <jvmarg value="-Daj5.def=ataspectj/aop-decptest2.xml"/>
         </java>
     </target>
+
+    <target name="ltw.oldAspectsDeclared">
+        <!--Aspects woven at compile time must be declared in an aop.xml file.
+        If they are not declared, then they will be lost during reweaving-->
+
+        <!--First test that the error is produced if the declaration is not made-->
+        <java fork="yes" classname="ataspectj.ltwreweavable.MainReweavableLogging" failonerror="yes">
+            <classpath refid="aj.path"/>
+            <classpath>
+                <pathelement path="${aj.sandbox}/main1.jar"/>
+            </classpath>
+            <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+            <jvmarg value="-Daj5.def=ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml"/>
+            <jvmarg value="-DaspectDeclared=true"/>
+        </java>
+        <!--Now ensure that the error is not produced when the declaration is made.-->
+        <java fork="yes" classname="ataspectj.ltwreweavable.MainReweavableLogging" failonerror="yes">
+            <classpath refid="aj.path"/>
+            <classpath>
+                <pathelement path="${aj.sandbox}/main1.jar"/>
+            </classpath>
+            <jvmarg value="-javaagent:${aj.root}/lib/test/loadtime5.jar"/>
+            <jvmarg value="-Daj5.def=ataspectj/ltwreweavable/aop-ltwreweavable-omitted.xml"/>
+            <jvmarg value="-DaspectDeclared=false"/>
+        </java>
+    </target>
+
 </project>
\ No newline at end of file
index fe04e96b100fb3eb71293ae5177dc42f15ca92e7..3e607df7d9172baaab314f910b56fa50eb9bf621 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <aspectj>
-    <weaver options="-XmessageHandlerClass:ataspectj.TestHelper"/>
+    <weaver options="-XmessageHandlerClass:ataspectj.TestHelper -1.5 -Xlint:ignore"/>
     <aspects>
         <aspect name="ataspectj.DeclareParentsImplementsTest.TestAspect"/>
         <aspect name="ataspectj.DeclareParentsInterfaceTest.TestAspect"/>
diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/AspectReweavableLogging.java b/tests/java5/ataspectj/ataspectj/ltwreweavable/AspectReweavableLogging.java
new file mode 100644 (file)
index 0000000..e921147
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Alexandre Vasseur         initial implementation
+ *******************************************************************************/
+package ataspectj.ltwreweavable;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+
+/**
+ * Contributed by David Knibb
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+@Aspect
+public class AspectReweavableLogging {
+
+        @Before("execution(void ataspectj.ltwreweavable.MainReweavableLogging.test1()) && this(a)")
+        public void before(Advisable a, JoinPoint thisJoinPoint) {
+            System.err.println(thisJoinPoint);
+            a.addJoinPoint(thisJoinPoint.getSignature().getName());
+    }
+}
+    
\ No newline at end of file
diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/MainReweavableLogging.java b/tests/java5/ataspectj/ataspectj/ltwreweavable/MainReweavableLogging.java
new file mode 100644 (file)
index 0000000..caa4a9a
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ * 
+ * Contributors:
+ *   Alexandre Vasseur         initial implementation
+ *******************************************************************************/
+package ataspectj.ltwreweavable;
+
+import ataspectj.ltwlog.MessageHolder;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * Contributed by David Knibb
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class MainReweavableLogging implements Advisable {
+    private static List joinPoints = new ArrayList();
+
+    public void test1 () {
+
+    }
+
+    public void test2 () {
+
+    }
+
+    public void addJoinPoint (String name) {
+        joinPoints.add(name);
+    }
+
+    public static void main (String[] args) {
+        String ERROR_STRING = "error aspect 'ataspectj.ltwreweavable.AspectReweavableLogging' woven into 'ataspectj.ltwreweavable.MainReweavableLogging' must be declared in an aop.xml file.";
+        if(Boolean.getBoolean("aspectDeclared")){
+            //if the aspect is declared there should not be an error
+            if (MessageHolder.startsAs( Arrays.asList(  new String[]{ ERROR_STRING }  )) ) {
+                MessageHolder.dump();
+                throw new RuntimeException("Error in MainReweavableLogging - unexpected error message - \"" + ERROR_STRING + "\"");
+            }
+        }
+        else{
+            //and if the aspect is not declared then there should
+            if (!MessageHolder.startsAs( Arrays.asList(  new String[]{ ERROR_STRING }  )) ) {
+                MessageHolder.dump();
+                throw new RuntimeException("Error in MainReweavableLogging - missing expected error message - \"" + ERROR_STRING + "\"");
+            }
+        }
+    }
+}
diff --git a/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml b/tests/java5/ataspectj/ataspectj/ltwreweavable/aop-ltwreweavable-declared.xml
new file mode 100644 (file)
index 0000000..d89b5b3
--- /dev/null
@@ -0,0 +1,6 @@
+<aspectj>
+    <weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/>
+    <aspects>
+        <aspect name="ataspectj.ltwreweavable.AspectReweavableLogging"/>
+    </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
new file mode 100644 (file)
index 0000000..4b53f2b
--- /dev/null
@@ -0,0 +1,5 @@
+<aspectj>
+    <weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/>
+    <!--aspect is not declared here so as to produce an error -->
+    <aspects/>
+</aspectj>
\ No newline at end of file
index 18c7c8b0258213b05e462e1282cc72578aa53201..79e3dc30734e60e96d247527f9967ab489f66fc0 100644 (file)
@@ -82,12 +82,16 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {
         runTest("LTW Unweavable");
     }
 
-    // FIXME asc need to comment this out for now - I need a build through...
-//    public void testLTWDecp() {
-//        runTest("LTW Decp");
-//    }
+    public void testLTWDecp() {
+        runTest("LTW Decp");
+    }
 
     public void testLTWDecp2() {
         runTest("LTW Decp2");
     }
+
+    public void testCompileTimeAspectsDeclaredToLTWWeaver() {
+        runTest("Compile time aspects declared to ltw weaver");
+    }
+
 }
index 11dd7e656cfc2023d9d20a72a02a25c8d9ede9fd..a316e67992ca36015f125d68c38eb7a6a254ea9c 100644 (file)
@@ -7,90 +7,90 @@
 
     <ajc-test dir="java5/ataspectj" title="AjcLTW PerClauseTest -XnoWeave">
         <compile
-            files="ataspectj/PerClauseTest.java,ataspectj/PerClauseTestAspects.java,ataspectj/TestHelper.java"
-            options="-1.5 -XnoWeave"/>
+                files="ataspectj/PerClauseTest.java,ataspectj/PerClauseTestAspects.java,ataspectj/TestHelper.java"
+                options="-1.5 -XnoWeave"/>
         <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="AjcLTW PerClauseTest -Xreweavable">
         <compile
-            files="ataspectj/PerClauseTest.java,ataspectj/PerClauseTestAspects.java,ataspectj/TestHelper.java"
-            options="-1.5"/>
+                files="ataspectj/PerClauseTest.java,ataspectj/PerClauseTestAspects.java,ataspectj/TestHelper.java"
+                options="-1.5"/>
         <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="JavaCAjcLTW PerClauseTest">
         <compile
-            files="ataspectj/PerClauseTest.java,ataspectj/TestHelper.java,ataspectj/PerClauseTestAspects.java"
-            options="-1.5 -XnoWeave"/>
+                files="ataspectj/PerClauseTest.java,ataspectj/TestHelper.java,ataspectj/PerClauseTestAspects.java"
+                options="-1.5 -XnoWeave"/>
         <comment>
-        aspectOf methods will be pushed in, ignore warning for adviceDidNotMatch but still do the logic for them
-        since such just added methods are an interesting case (percflow ajc$perCflowStack advice)
+            aspectOf methods will be pushed in, ignore warning for adviceDidNotMatch but still do the logic for them
+            since such just added methods are an interesting case (percflow ajc$perCflowStack advice)
         </comment>
         <compile
-            files="ataspectj/PerClauseTestAspects.java"
-            options="-1.5 -Xdev:NoAtAspectJProcessing">
-                <message kind="warning"/>
+                files="ataspectj/PerClauseTestAspects.java"
+                options="-1.5 -Xdev:NoAtAspectJProcessing">
+            <message kind="warning"/>
         </compile>
         <ant file="ajc-ant.xml" target="ltw.PerClauseTest" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -XnoWeave">
         <compile
-            files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java"
-            options="-1.5 -XnoWeave"/>
+                files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java"
+                options="-1.5 -XnoWeave"/>
         <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -Xreweavable">
         <compile
-            files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java"
-            options="-1.5"/>
+                files="ataspectj/AroundInlineMungerTest.java,ataspectj/AroundInlineMungerTestAspects.java,ataspectj/TestHelper.java"
+                options="-1.5"/>
         <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest">
         <compile
-            files="ataspectj/AroundInlineMungerTestAspects.java"
-            options="-1.5 -Xlint:ignore"/>
+                files="ataspectj/AroundInlineMungerTestAspects.java"
+                options="-1.5 -Xlint:ignore"/>
         <compile
-            files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java"
-            options="-1.5"/>
+                files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java"
+                options="-1.5"/>
         <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest -XnoInline -Xreweavable">
         <compile
-            files="ataspectj/AroundInlineMungerTestAspects.java"
-            options="-1.5 -Xlint:ignore -XnoInline"/>
+                files="ataspectj/AroundInlineMungerTestAspects.java"
+                options="-1.5 -Xlint:ignore -XnoInline"/>
         <compile
-            files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java"
-            options="-1.5 -XnoInline"/>
+                files="ataspectj/AroundInlineMungerTest.java,ataspectj/TestHelper.java"
+                options="-1.5 -XnoInline"/>
         <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="AjcLTW AroundInlineMungerTest2">
         <compile
-            files="ataspectj/AroundInlineMungerTestAspects2.aj"
-            options="-1.5 -Xlint:ignore"/>
+                files="ataspectj/AroundInlineMungerTestAspects2.aj"
+                options="-1.5 -Xlint:ignore"/>
         <compile
-            files="ataspectj/AroundInlineMungerTest2.aj,ataspectj/TestHelper.java"
-            options="-1.5"/>
+                files="ataspectj/AroundInlineMungerTest2.aj,ataspectj/TestHelper.java"
+                options="-1.5"/>
         <ant file="ajc-ant.xml" target="ltw.AroundInlineMungerTest2" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="LTW DumpTest">
         <compile
-            files="ataspectj/DumpTest.java,ataspectj/DumpTestTheDump.java,ataspectj/TestHelper.java"
-            options="-1.5"/>
+                files="ataspectj/DumpTest.java,ataspectj/DumpTestTheDump.java,ataspectj/TestHelper.java"
+                options="-1.5"/>
         <ant file="ajc-ant.xml" target="ltw.DumpTest" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="Ajc Aspect1 LTW Aspect2 -Xreweavable">
         <compile
-            files="ataspectj/ltwreweavable/Main.java,ataspectj/ltwreweavable/Aspect1.java,ataspectj/ltwreweavable/Advisable.java"
-            options="-1.5"
-            outjar="main1.jar"/>
+                files="ataspectj/ltwreweavable/Main.java,ataspectj/ltwreweavable/Aspect1.java,ataspectj/ltwreweavable/Advisable.java"
+                options="-1.5"
+                outjar="main1.jar"/>
         <ant file="ajc-ant.xml" target="ltw.Aspect2MainTest" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="LTW Decp">
         <!-- ajc compile them to test reweable as well -->
         <compile
-            files="ataspectj/DeclareParentsInterfaceTest.java,ataspectj/DeclareParentsImplementsTest.java,ataspectj/TestHelper.java"
-            options="-1.5"
-            />
+                files="ataspectj/DeclareParentsInterfaceTest.java,ataspectj/DeclareParentsImplementsTest.java,ataspectj/TestHelper.java"
+                options="-1.5"
+                />
+        <!--<run class="ataspectj.DeclareParentsInterfaceTest" ltw="ataspectj/aop-decptest.xml"/>-->
         <ant file="ajc-ant.xml" target="ltw.Decp" verbose="true"/>
     </ajc-test>
 
     <ajc-test dir="java5/ataspectj" title="LTW Decp2">
         <!-- ajc compile them but with only one aspect -->
         <compile
-            files="ataspectj/DeclareParentsImplementsReweavableTest.java,ataspectj/TestHelper.java"
-            options="-1.5"
-            />
+                files="ataspectj/DeclareParentsImplementsReweavableTest.java,ataspectj/TestHelper.java"
+                options="-1.5"
+                />
         <!-- compile the other aspect alone (won't be applied) -->
         <ant file="ajc-ant.xml" target="ltw.Decp2" verbose="true"/>
     </ajc-test>
+
+
+    <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"
+                options="-1.5"
+                outjar="main1.jar"/>
+        <ant file="ajc-ant.xml" target="ltw.oldAspectsDeclared" verbose="true"/>
+    </ajc-test>
+
 </suite>
\ No newline at end of file
index aa0fdd8dcd23270e5aec4b97e834b4a0755c8031..5cccccd7684e4218ec76e55d38facadb3874013c 100644 (file)
@@ -71,8 +71,9 @@ public class WeaverMessages {
        public static final String MISSING_REWEAVABLE_TYPE = "missingReweavableType";
        public static final String VERIFIED_REWEAVABLE_TYPE = "verifiedReweavableType";
        public static final String ASPECT_NEEDED = "aspectNeeded";
-       
-       public static final String CANT_FIND_TYPE = "cantFindType";
+    public static final String REWEAVABLE_ASPECT_NOT_REGISTERED = "reweavableAspectNotRegistered";
+
+    public static final String CANT_FIND_TYPE = "cantFindType";
        public static final String CANT_FIND_CORE_TYPE = "cantFindCoreType";
        public static final String CANT_FIND_TYPE_WITHINPCD = "cantFindTypeWithinpcd";
     public static final String CANT_FIND_TYPE_DURING_AROUND_WEAVE = "cftDuringAroundWeave";
index 20fb8179280e7bd28f4441ca2ba1df17a6ed1385..36b65d38196df57cb6bdee1ce89515ba5b652601 100644 (file)
@@ -938,8 +938,8 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
                     for (int i = 0; i < annotationsOnRealMember.length; i++) {
                         AnnotationX annotationX = annotationsOnRealMember[i];
                         Annotation a = annotationX.getBcelAnnotation();
-                        AnnotationGen ag = new AnnotationGen(a,weaver.getLazyClassGen().getConstantPoolGen(),true);
-                        mg.addAnnotation(new AnnotationX(ag.getAnnotation(),weaver.getWorld()));
+                        AnnotationGen ag = new AnnotationGen(a, weaver.getLazyClassGen().getConstantPoolGen(), true);
+                        mg.addAnnotation(new AnnotationX(ag.getAnnotation(), weaver.getWorld()));
                     }
                 }
             }
index 70db78792a3c1c5e828741c324df38cb8dcc0a09..cf4c2992724e7f52b140e91ef178cf1d1f3fe26e 100644 (file)
@@ -1179,11 +1179,25 @@ public class BcelWeaver implements IWeaver {
                                                                        WeaverMessages.format(WeaverMessages.MISSING_REWEAVABLE_TYPE,requiredTypeName,className),
                                                                    classType.getSourceLocation(), null);
                                                } else {
-                                                       if (!world.getMessageHandler().isIgnoring(IMessage.INFO))
-                                                         world.showMessage(IMessage.INFO,
+                            // weaved in aspect that are not declared in aop.xml trigger an error for now
+                            // may cause headhache for LTW and packaged lib without aop.xml in
+                            // see #104218
+                            if(!xcutSet.containsAspect(rtx)){
+                                world.showMessage(
+                                        IMessage.ERROR,
+                                        WeaverMessages.format(
+                                                WeaverMessages.REWEAVABLE_ASPECT_NOT_REGISTERED,
+                                                requiredTypeName,
+                                                className
+                                        ),
+                                        null,
+                                        null
+                                );
+                            } else if (!world.getMessageHandler().isIgnoring(IMessage.INFO))
+                                                           world.showMessage(IMessage.INFO,
                                                                        WeaverMessages.format(WeaverMessages.VERIFIED_REWEAVABLE_TYPE,requiredTypeName,rtx.getSourceLocation().getSourceFile()),
                                                                        null,null);
-                                                       alreadyConfirmedReweavableState.add(requiredTypeName);
+                                                           alreadyConfirmedReweavableState.add(requiredTypeName);
                                                }
                                        }               
                                }
index 9290f35340178717d08da5e05d15c0a2b35b30e7..08f9fd2a33ed2fec73c0a36d3e70291a90a891e2 100644 (file)
@@ -73,6 +73,7 @@ processingReweavable=processing reweavable type {0}: {1}
 missingReweavableType=type {0} is needed by reweavable type {1}
 verifiedReweavableType=successfully verified type {0} exists.  Originates from {1}
 aspectNeeded=aspect {0} is needed when using type {1}
+reweavableAspectNotRegistered=aspect ''{0}'' woven into ''{1}'' must be declared in an aop.xml file.
 
 # The infamous and deserving a category all of its own...
 cantFindType=can''t find type {0}