Browse Source

tests and fixes for 93345 and static imports. From Andrew Huff.

tags/PRE_ANDY
aclement 19 years ago
parent
commit
f6034581d8

+ 12
- 0
tests/bugs150/PR93345.aj View File

@@ -0,0 +1,12 @@
// "XLint warning for advice not applied with cflow(execution)"

class AClass {
}

aspect AnAspect {
pointcut a() : cflow( execution(* *(..)) );

before() : a() {
System.out.println("before a");
}
}

+ 9
- 0
tests/java5/staticImports/StaticImport.aj View File

@@ -0,0 +1,9 @@
// "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");
}
}

+ 1
- 0
tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java View File

@@ -34,6 +34,7 @@ public class AllTestsAspectJ150 {
suite.addTest(AnnotationsBinaryWeaving.suite());
suite.addTest(AnnotationPointcutsTests.suite());
suite.addTestSuite(VarargsTests.class);
suite.addTestSuite(StaticImports.class);
suite.addTest(AnnotationRuntimeTests.suite());
suite.addTestSuite(PerTypeWithinTests.class);

+ 33
- 0
tests/src/org/aspectj/systemtest/ajc150/StaticImports.java View File

@@ -0,0 +1,33 @@
/*******************************************************************************
* 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");
}

}

+ 4
- 1
tests/src/org/aspectj/systemtest/ajc150/SuppressedWarnings.java View File

@@ -42,5 +42,8 @@ public class SuppressedWarnings extends XMLBasedAjcTestCase {
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)");
}
}

+ 10
- 0
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml View File

@@ -5,6 +5,10 @@

<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."/>
@@ -1054,6 +1058,12 @@
<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 -->

+ 10
- 9
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java View File

@@ -995,6 +995,7 @@ public class BcelWeaver implements IWeaver {
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()) {
@@ -1003,15 +1004,15 @@ public class BcelWeaver implements IWeaver {
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());
}
}
}
}
}

Loading…
Cancel
Save