--- /dev/null
+// "XLint warning for advice not applied with cflow(execution)"
+
+class AClass {
+}
+
+aspect AnAspect {
+ pointcut a() : cflow( execution(* *(..)) );
+
+ before() : a() {
+ System.out.println("before a");
+ }
+}
\ No newline at end of file
--- /dev/null
+// "import static java.lang.System.out"
+
+import static java.lang.System.out;
+
+public class StaticImport{
+ public static void main(String [] args){
+ out.println("hello world");
+ }
+}
suite.addTest(AnnotationsBinaryWeaving.suite());
suite.addTest(AnnotationPointcutsTests.suite());
suite.addTestSuite(VarargsTests.class);
+ suite.addTestSuite(StaticImports.class);
suite.addTest(AnnotationRuntimeTests.suite());
suite.addTestSuite(PerTypeWithinTests.class);
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Andrew Huff - initial implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc150;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+public class StaticImports extends XMLBasedAjcTestCase {
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(StaticImports.class);
+ }
+
+ protected File getSpecFile() {
+ return new File("../tests/src/org/aspectj/systemtest/ajc150/ajc150.xml");
+ }
+
+ public void testImportStaticSystemDotOut() {
+ runTest("import static java.lang.System.out");
+ }
+
+}
public void testSuppression2() {
runTest("suppressing non-matching advice warnings when multiple source files involved");
}
-
+
+ public void testSuppressionWithCflow_pr93345() {
+ runTest("XLint warning for advice not applied with cflow(execution)");
+ }
}
\ No newline at end of file
<suite>
+ <ajc-test dir="java5/staticImports" title="import static java.lang.System.out">
+ <compile files="StaticImport.aj" options="-1.5"/>
+ </ajc-test>
+
<ajc-test dir="java5/bridgeMethods" pr="72766" title="Ignore bridge methods">
<compile files="AspectX.aj" inpath="testcode.jar" options="-showWeaveInfo">
<message kind="warning" line="7" text="pointcut did not match on the method call to a bridge method."/>
<message kind="warning" line="11" file="A3.aj"/>
</compile>
</ajc-test>
+
+ <ajc-test dir="bugs150" title="XLint warning for advice not applied with cflow(execution)" pr="93345">
+ <compile options="-Xlint,-1.5" files="PR93345.aj" >
+ <message kind="warning" line="7" text="advice defined in AnAspect has not been applied [Xlint:adviceDidNotMatch]"/>
+ </compile>
+ </ajc-test>
<!-- ======================================================================================= -->
<!-- annotated aspect members -->
deletedTypenames = new ArrayList();
+ // FIXME asc Should be factored out into Xlint code and done automatically for all xlint messages, ideally.
// if a piece of advice hasn't matched anywhere and we are in -1.5 mode, put out a warning
if (world.behaveInJava5Way &&
world.getLint().adviceDidNotMatch.isEnabled()) {
ShadowMunger element = (ShadowMunger) iter.next();
if (element instanceof BcelAdvice) { // This will stop us incorrectly reporting deow Checkers
BcelAdvice ba = (BcelAdvice)element;
- if (!ba.hasMatchedSomething()) {
- BcelMethod meth = (BcelMethod)ba.getSignature();
- if (meth!=null) {
- AnnotationX[] anns = (AnnotationX[])meth.getAnnotations();
- // Check if they want to suppress the warning on this piece of advice
- if (!Utility.isSuppressing(anns,"adviceDidNotMatch")) {
- world.getLint().adviceDidNotMatch.signal(ba.getDeclaringAspect().toString(),element.getSourceLocation());
- }
- }
+ if (!ba.hasMatchedSomething()) {
+ // Because we implement some features of AJ itself by creating our own kind of mungers, you sometimes
+ // find that ba.getSignature() is not a BcelMethod - for example it might be a cflow entry munger.
+ if (ba.getSignature()!=null) {
+ if (!(ba.getSignature() instanceof BcelMethod)
+ || !Utility.isSuppressing((AnnotationX[])ba.getSignature().getAnnotations(),"adviceDidNotMatch")) {
+ world.getLint().adviceDidNotMatch.signal(ba.getDeclaringAspect().toString(),element.getSourceLocation());
+ }
+ }
}
}
}