impl error message for reweavable and not declared in aop.xml as per David Knibb patch, #104218
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
<?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"/>
--- /dev/null
+/*******************************************************************************
+ * 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
--- /dev/null
+/*******************************************************************************
+ * 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 + "\"");
+ }
+ }
+ }
+}
--- /dev/null
+<aspectj>
+ <weaver options="-XmessageHandlerClass:ataspectj.ltwlog.MessageHolder"/>
+ <aspects>
+ <aspect name="ataspectj.ltwreweavable.AspectReweavableLogging"/>
+ </aspects>
+</aspectj>
\ No newline at end of file
--- /dev/null
+<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
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");
+ }
+
}
<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
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";
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()));
}
}
}
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);
}
}
}
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}