summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java31
-rw-r--r--testing/newsrc/org/aspectj/testing/OutputSpec.java3
-rw-r--r--testing/newsrc/org/aspectj/testing/RunSpec.java23
-rw-r--r--testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java1
-rw-r--r--tests/ltw/Aspect3.aj19
-rw-r--r--tests/ltw/Xlint-empty.properties0
-rw-r--r--tests/ltw/Xlint-nomatch.properties1
-rw-r--r--tests/ltw/aop-nomatch.xml7
-rw-r--r--tests/ltw/aop-nomatchxlint.xml7
-rw-r--r--tests/ltw/aop-nomatchxlintfile.xml7
-rw-r--r--tests/ltw/aop-xlintfile.xml3
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java24
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml107
-rw-r--r--weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java2
-rw-r--r--weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java7
15 files changed, 220 insertions, 22 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
index b17392d05..d889fbdc0 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
@@ -25,9 +25,7 @@ import java.util.Properties;
import java.util.StringTokenizer;
import org.aspectj.asm.IRelationship;
-import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.bridge.Message;
import org.aspectj.util.LangUtil;
import org.aspectj.weaver.ICrossReferenceHandler;
import org.aspectj.weaver.Lint;
@@ -220,7 +218,14 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
world.setXnoInline(weaverOption.noInline);
// AMC - autodetect as per line below, needed for AtAjLTWTests.testLTWUnweavable
world.setBehaveInJava5Way(LangUtil.is15VMOrGreater());
- //-Xlintfile: first so that lint wins
+
+ /* First load defaults */
+ bcelWorld.getLint().loadDefaultProperties();
+
+ /* Second overlay LTW defaults */
+ bcelWorld.getLint().adviceDidNotMatch.setKind(null);
+
+ /* Third load user file using -Xlintfile so that -Xlint wins */
if (weaverOption.lintFile != null) {
InputStream resource = null;
try {
@@ -236,20 +241,20 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
}
}
if (failure != null || resource == null) {
- world.getMessageHandler().handleMessage(new Message(
- "Cannot access resource for -Xlintfile:"+weaverOption.lintFile,
- IMessage.WARNING,
- failure,
- null));
+ warn("Cannot access resource for -Xlintfile:"+weaverOption.lintFile,failure);
+// world.getMessageHandler().handleMessage(new Message(
+// "Cannot access resource for -Xlintfile:"+weaverOption.lintFile,
+// IMessage.WARNING,
+// failure,
+// null));
}
} finally {
try { resource.close(); } catch (Throwable t) {;}
}
- }
- if (weaverOption.lint == null) {
- bcelWorld.getLint().loadDefaultProperties();
- bcelWorld.getLint().adviceDidNotMatch.setKind(IMessage.INFO);
- } else {
+ }
+
+ /* Fourth override with -Xlint */
+ if (weaverOption.lint != null) {
if (weaverOption.lint.equals("default")) {//FIXME should be AjBuildConfig.AJLINT_DEFAULT but yetanother deps..
bcelWorld.getLint().loadDefaultProperties();
} else {
diff --git a/testing/newsrc/org/aspectj/testing/OutputSpec.java b/testing/newsrc/org/aspectj/testing/OutputSpec.java
index be869bfbb..45a7a02d6 100644
--- a/testing/newsrc/org/aspectj/testing/OutputSpec.java
+++ b/testing/newsrc/org/aspectj/testing/OutputSpec.java
@@ -35,7 +35,8 @@ public class OutputSpec {
String line = (String) iter.next();
lineNo++;
String outputLine = strTok.nextToken().trim();
- if (!line.equals(outputLine)) {
+ /* Avoid trying to match on ajSandbox source names that appear in messages */
+ if (outputLine.indexOf(line) == -1) {
matches = false;
break;
}
diff --git a/testing/newsrc/org/aspectj/testing/RunSpec.java b/testing/newsrc/org/aspectj/testing/RunSpec.java
index 166c2d89e..b879c95a2 100644
--- a/testing/newsrc/org/aspectj/testing/RunSpec.java
+++ b/testing/newsrc/org/aspectj/testing/RunSpec.java
@@ -37,6 +37,7 @@ public class RunSpec implements ITestStep {
private OutputSpec stdErrSpec;
private OutputSpec stdOutSpec;
private String ltwFile;
+ private String xlintFile;
public RunSpec() {
}
@@ -51,6 +52,7 @@ public class RunSpec implements ITestStep {
String[] args = buildArgs();
// System.err.println("? execute() inTestCase='" + inTestCase + "', ltwFile=" + ltwFile);
boolean useLtw = copyLtwFile(inTestCase.getSandboxDirectory());
+ copyXlintFile(inTestCase.getSandboxDirectory());
AjcTestCase.RunResult rr = inTestCase.run(getClassToRun(),args,getClasspath(),useLtw);
if (stdErrSpec != null) {
stdErrSpec.matchAgainst(rr.getStdErr());
@@ -147,4 +149,25 @@ public class RunSpec implements ITestStep {
return useLtw;
}
+
+ public String getXlintFile() {
+ return xlintFile;
+ }
+
+ public void setXlintFile(String xlintFile) {
+ this.xlintFile = xlintFile;
+ }
+
+ private void copyXlintFile (File sandboxDirectory) {
+ if (xlintFile != null) {
+ File from = new File(baseDir,xlintFile);
+ File to = new File(sandboxDirectory, File.separator + xlintFile);
+ try {
+ FileUtil.copyFile(from,to);
+ }
+ catch (IOException ex) {
+ AjcTestCase.fail(ex.toString());
+ }
+ }
+ }
}
diff --git a/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java
index 58a5f0d33..fbefbccb2 100644
--- a/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java
+++ b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCase.java
@@ -167,6 +167,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase {
digester.addObjectCreate("suite/ajc-test/run",RunSpec.class);
digester.addSetProperties("suite/ajc-test/run","class","classToRun");
digester.addSetProperties("suite/ajc-test/run","ltw","ltwFile");
+ digester.addSetProperties("suite/ajc-test/run","xlintfile","xlintFile");
digester.addSetNext("suite/ajc-test/run","addTestStep","org.aspectj.testing.ITestStep");
digester.addObjectCreate("*/message",ExpectedMessageSpec.class);
digester.addSetProperties("*/message");
diff --git a/tests/ltw/Aspect3.aj b/tests/ltw/Aspect3.aj
new file mode 100644
index 000000000..c27d9e1c2
--- /dev/null
+++ b/tests/ltw/Aspect3.aj
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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:
+ * Matthew Webster initial implementation
+ *******************************************************************************/
+import org.aspectj.lang.JoinPoint;
+
+public aspect Aspect3 {
+
+ before () : execution(void Main.test999()) {
+ System.err.println("Aspect1.before_" + thisJoinPoint.getSignature().getName());
+ }
+}
diff --git a/tests/ltw/Xlint-empty.properties b/tests/ltw/Xlint-empty.properties
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/ltw/Xlint-empty.properties
diff --git a/tests/ltw/Xlint-nomatch.properties b/tests/ltw/Xlint-nomatch.properties
new file mode 100644
index 000000000..00f96a1c9
--- /dev/null
+++ b/tests/ltw/Xlint-nomatch.properties
@@ -0,0 +1 @@
+adviceDidNotMatch = warning
diff --git a/tests/ltw/aop-nomatch.xml b/tests/ltw/aop-nomatch.xml
new file mode 100644
index 000000000..620a4c77e
--- /dev/null
+++ b/tests/ltw/aop-nomatch.xml
@@ -0,0 +1,7 @@
+<aspectj>
+ <aspects>
+ <aspect name="Aspect3"/>
+ </aspects>
+
+ <weaver options="-verbose -showWeaveInfo"/>
+</aspectj>
diff --git a/tests/ltw/aop-nomatchxlint.xml b/tests/ltw/aop-nomatchxlint.xml
new file mode 100644
index 000000000..4271e394d
--- /dev/null
+++ b/tests/ltw/aop-nomatchxlint.xml
@@ -0,0 +1,7 @@
+<aspectj>
+ <aspects>
+ <aspect name="Aspect3"/>
+ </aspects>
+
+ <weaver options="-verbose -showWeaveInfo -Xlint:warning"/>
+</aspectj>
diff --git a/tests/ltw/aop-nomatchxlintfile.xml b/tests/ltw/aop-nomatchxlintfile.xml
new file mode 100644
index 000000000..35ce126e3
--- /dev/null
+++ b/tests/ltw/aop-nomatchxlintfile.xml
@@ -0,0 +1,7 @@
+<aspectj>
+ <aspects>
+ <aspect name="Aspect3"/>
+ </aspects>
+
+ <weaver options="-verbose -showWeaveInfo -Xlintfile:Xlint-nomatch.properties"/>
+</aspectj>
diff --git a/tests/ltw/aop-xlintfile.xml b/tests/ltw/aop-xlintfile.xml
new file mode 100644
index 000000000..31d7bad16
--- /dev/null
+++ b/tests/ltw/aop-xlintfile.xml
@@ -0,0 +1,3 @@
+<aspectj>
+ <weaver options="-Xlintfile:Xlint-empty.properties"/>
+</aspectj>
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java b/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java
index ffb52a905..57ca49810 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/ltw/LTWTests.java
@@ -65,6 +65,30 @@ public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase {
runTest("Ensure weaver lint warning issued when an aspect is not used for weaving");
}
+ public void testXlintfileEmpty () {
+ runTest("Empty Xlint.properties file");
+ }
+
+ public void testXlintfileMissing () {
+ runTest("Warning with missing Xlint.properties file");
+ }
+
+ public void testXlintWarningAdviceDidNotMatchSuppressed () {
+ runTest("Warning when advice doesn't match suppressed for LTW");
+ }
+
+ public void testXlintfile () {
+ runTest("Override suppressing of warning when advice doesn't match using -Xlintfile");
+ }
+
+ public void testXlintDefault () {
+ runTest("Warning when advice doesn't match using -Xlint:default");
+ }
+
+ public void testXlintWarning () {
+ runTest("Override suppressing of warning when advice doesn't match using -Xlint:warning");
+ }
+
/*
* Allow system properties to be set and restored
* TODO maw move to XMLBasedAjcTestCase or RunSpec
diff --git a/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml b/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml
index 69eff31ee..284357e42 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml
+++ b/tests/src/org/aspectj/systemtest/ajc150/ltw/ltw-tests.xml
@@ -1,3 +1,4 @@
+
<!-- Load-time weaving tests -->
<ajc-test dir="ltw"
@@ -215,3 +216,109 @@
</run>
</ajc-test>
+ <ajc-test dir="ltw"
+ title="Empty Xlint.properties file"
+ keywords="xlint, ltw">
+ <compile
+ files="Main.java"
+ >
+ </compile>
+ <run class="Main" ltw="aop-xlintfile.xml" xlintfile="Xlint-empty.properties">
+ <stderr>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="ltw"
+ title="Warning with missing Xlint.properties file"
+ keywords="xlint, ltw">
+ <compile
+ files="Main.java"
+ >
+ </compile>
+ <run class="Main" ltw="aop-xlintfile.xml">
+ <stderr>
+ <line text="warning Cannot access resource for -Xlintfile:Xlint-empty.properties"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="ltw"
+ title="Warning when advice doesn't match suppressed for LTW"
+ keywords="xlint, ltw">
+ <compile
+ files="Main.java"
+ >
+ </compile>
+ <compile
+ files="Aspect3.aj"
+ >
+ </compile>
+ <run class="Main" ltw="aop-nomatch.xml">
+ <stderr>
+ <line text="info register aspect Aspect3"/>
+ <line text="info weaving 'Main'"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="ltw"
+ title="Override suppressing of warning when advice doesn't match using -Xlintfile"
+ keywords="xlint, ltw">
+ <compile
+ files="Main.java"
+ >
+ </compile>
+ <compile
+ files="Aspect3.aj"
+ >
+ </compile>
+ <run class="Main" ltw="aop-nomatchxlintfile.xml" xlintfile="Xlint-nomatch.properties">
+ <stderr>
+ <line text="info register aspect Aspect3"/>
+ <line text="info weaving 'Main'"/>
+ <line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="ltw"
+ title="Warning when advice doesn't match using -Xlint:default"
+ keywords="xlint, ltw">
+ <compile
+ files="Main.java"
+ >
+ </compile>
+ <compile
+ files="Aspect3.aj"
+ >
+ </compile>
+ <run class="Main" ltw="aop-nomatchxlint.xml">
+ <stderr>
+ <line text="info register aspect Aspect3"/>
+ <line text="info weaving 'Main'"/>
+ <line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
+ <ajc-test dir="ltw"
+ title="Override suppressing of warning when advice doesn't match using -Xlint:warning"
+ keywords="xlint, ltw">
+ <compile
+ files="Main.java"
+ >
+ </compile>
+ <compile
+ files="Aspect3.aj"
+ >
+ </compile>
+ <run class="Main" ltw="aop-nomatchxlint.xml">
+ <stderr>
+ <line text="info register aspect Aspect3"/>
+ <line text="info weaving 'Main'"/>
+ <line text="advice defined in Aspect3 has not been applied [Xlint:adviceDidNotMatch]"/>
+ </stderr>
+ </run>
+ </ajc-test>
+
diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java
index 398a0b4f3..3aeaa7f70 100644
--- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java
+++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java
@@ -332,7 +332,7 @@ public class WeavingAdaptor {
}
protected boolean warn (String message, Throwable th) {
- return messageHandler.handleMessage(new Message("Register definition failed", IMessage.WARNING, th, null));
+ return messageHandler.handleMessage(new Message(message, IMessage.WARNING, th, null));
}
protected boolean error (String message) {
diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
index 502dd80fb..d153ccdc7 100644
--- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
+++ b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
@@ -15,25 +15,18 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
-import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
-import java.lang.reflect.WildcardType;
-import java.util.HashMap;
-import java.util.Map;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.AjType;
import org.aspectj.lang.reflect.AjTypeSystem;
import org.aspectj.lang.reflect.Pointcut;
import org.aspectj.weaver.AnnotationX;
-import org.aspectj.weaver.BoundedReferenceType;
import org.aspectj.weaver.ReferenceType;
import org.aspectj.weaver.ResolvedMember;
import org.aspectj.weaver.ResolvedPointcutDefinition;
import org.aspectj.weaver.ResolvedType;
-import org.aspectj.weaver.TypeFactory;
import org.aspectj.weaver.TypeVariable;
import org.aspectj.weaver.TypeVariableReferenceType;
import org.aspectj.weaver.UnresolvedType;