aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2005-05-04 14:37:41 +0000
committeraclement <aclement>2005-05-04 14:37:41 +0000
commit70b9ffd2ceb86d00443d68931e8265ee9a8f8fa7 (patch)
tree3ef32dbc7abf26cd619d9191b7c62cbf4c721178
parent7e56f52c8d248aa7b20d27ec53e5f860ae07eeef (diff)
downloadaspectj-70b9ffd2ceb86d00443d68931e8265ee9a8f8fa7.tar.gz
aspectj-70b9ffd2ceb86d00443d68931e8265ee9a8f8fa7.zip
enhancement 91719 - Oli B's tests for xlint warnings, integration work done by Andrew Huff.
-rw-r--r--tests/bugs/seven/lint/Main.java180
-rw-r--r--tests/src/org/aspectj/systemtest/xlint/XLintTests.java4
-rw-r--r--tests/src/org/aspectj/systemtest/xlint/xlint-tests.xml19
3 files changed, 203 insertions, 0 deletions
diff --git a/tests/bugs/seven/lint/Main.java b/tests/bugs/seven/lint/Main.java
new file mode 100644
index 000000000..20d0fc242
--- /dev/null
+++ b/tests/bugs/seven/lint/Main.java
@@ -0,0 +1,180 @@
+/*
+ * 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
+ *
+ * Created on 25.03.2005
+ *
+ * Contributors
+ * Oliver Boehm initial implementation
+ */
+
+
+import java.io.Serializable;
+import org.aspectj.lang.annotation.SuppressAjWarnings;
+
+/**
+ * Test Aspect to check the different Xlint warnings
+ */
+aspect XlintTest {
+
+ /*
+ * examples for "invalidAbsoluteTypeName"
+ */
+
+ pointcut correctName() :
+ call(String java.lang.Object.toString());
+
+ pointcut wrongPackageName() :
+ call(String java.xxx.Object.toString());
+
+ pointcut wrongTypeName() :
+ call(String java.lang.Xxx.toString());
+
+ /** no warning!!! */
+ pointcut wrongMethodName() :
+ call(String java.lang.Object.xxx());
+
+ @SuppressAjWarnings
+ after() : call(String java.lang.Xxx.toString()) {
+ System.out.println(thisJoinPoint);
+ }
+
+
+
+ /*
+ * no example for "invalidWildcardTypeName"
+ *
+ * Never signalled anywhere in the codebase
+ * @see http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01404.html
+ */
+
+
+
+ /*
+ * example for "unresolvableMember"
+ *
+ * hard to reproduce - I tried different things but at last I give up
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=59596#c2
+ */
+
+
+
+ /*
+ * example for "typeNotExposedToWeaver"
+ */
+
+ public int Object.dummy = 0;
+
+
+
+ /*
+ * no example for "shadowNotInStructure"
+ *
+ * Signalled if the structure model is broken, probably can't happen
+ * @see http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg01404.html
+ */
+
+
+
+ /*
+ * example for "unmatchedSuperTypeInCall"
+ */
+
+ pointcut unmatchedToStringCall() :
+ call(String Car.toString());
+
+ pointcut matchedToStringCall() :
+ call(String Object.toString()) && target(Car);
+
+ before() : unmatchedToStringCall() && !within(XlintTest) {
+ System.out.println(thisJoinPoint);
+ }
+
+ @SuppressAjWarnings
+ before() : call(String Car.toString()) {
+ System.out.println(thisJoinPoint);
+ }
+
+ @SuppressAjWarnings({"adviceDidNotMatch"})
+ before() : call(* java.lang.String.helloWorld()) {
+ System.out.println(thisJoinPoint);
+ }
+
+
+ /*
+ * example for "canNotImplementLazyTjp"
+ *
+ * This example is from the README-12.html. To get the warning you must
+ * compile it with "-XlazyTjp"
+ *
+ * NOTE: The expected warnung does not appear. I don't know why.
+ * Here is the commandline:
+ * ajc -XlazyTjp -Xlint:warning -inpath src -d classes src
+ */
+
+ public static boolean enabled = false;
+
+ pointcut toBeTraced() : execution(* *(..)) && !within(XlintTest);
+
+ Object around() : toBeTraced() && if(enabled) {
+ Object[] args = thisJoinPoint.getArgs();
+ System.out.println(thisJoinPoint + ", arg's: " + args.length);
+ return proceed();
+ }
+
+
+
+ /*
+ * example for "needsSerialVersionUIDField"
+ */
+
+ declare parents : Main implements java.io.Serializable;
+
+
+
+ /*
+ * example for "brokeSerialVersionCompatibility"
+ *
+ * NOTE: I don't see this warning inside Eclipse with
+ * AJDT 1.2.0.20050308091611 although I activate the warning
+ * via the project properties.
+ * I see it only when I start the compiler from the commandline
+ * (ajc -XlazyTjp -Xlint:warning -inpath src -d classes src/x/...)
+ */
+
+ public int Car.breakSerial = 1;
+
+
+
+ /*
+ * example for "noInterfaceCtorJoinpoint"
+ */
+
+ pointcut interfaceConstructor() :
+ execution(java.util.List.new());
+
+}
+
+class Car implements Serializable {}
+
+
+public class Main extends Object {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ new Main().run();
+ Long l = new Long(1);
+ String s = l.toString();
+ }
+
+ public void run() {
+ new Car().toString();
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/xlint/XLintTests.java b/tests/src/org/aspectj/systemtest/xlint/XLintTests.java
index d3c1c54aa..bc31612a2 100644
--- a/tests/src/org/aspectj/systemtest/xlint/XLintTests.java
+++ b/tests/src/org/aspectj/systemtest/xlint/XLintTests.java
@@ -99,6 +99,10 @@ public class XLintTests extends org.aspectj.testing.XMLBasedAjcTestCase {
public void test019(){
runTest("XLint warning for call PCD's using subtype of defining type (-1.3 -Xlint:ignore)");
}
+
+ public void test020(){
+ runTest("7 lint warnings");
+ }
}
diff --git a/tests/src/org/aspectj/systemtest/xlint/xlint-tests.xml b/tests/src/org/aspectj/systemtest/xlint/xlint-tests.xml
index 150aa984a..68eb20496 100644
--- a/tests/src/org/aspectj/systemtest/xlint/xlint-tests.xml
+++ b/tests/src/org/aspectj/systemtest/xlint/xlint-tests.xml
@@ -158,4 +158,23 @@
</compile>
</ajc-test>
+ <ajc-test dir="bugs/seven/lint" title="7 lint warnings" pr="91719">
+ <compile options="-1.5" files="Main.java">
+ <message kind="warning" line="31" text="no match for this type name: java.xxx.Object [Xlint:invalidAbsoluteTypeName]">
+ </message>
+ <message kind="warning" line="34" text="no match for this type name: java.lang.Xxx [Xlint:invalidAbsoluteTypeName]">
+ </message>
+ <message kind="warning" line="41" text="no match for this type name: java.lang.Xxx [Xlint:invalidAbsoluteTypeName]">
+ </message>
+ <message kind="warning" line="69" text="this affected type is not exposed to the weaver: java.lang.Object [Xlint:typeNotExposedToWeaver]">
+ </message>
+ <message kind="warning" line="87" text="does not match because declaring type is java.lang.Object, if match desired use target(Car) [Xlint:unmatchedSuperTypeInCall]">
+ </message>
+ <message kind="warning" line="92" text="advice defined in XlintTest has not been applied [Xlint:adviceDidNotMatch]">
+ </message>
+ <message kind="warning" line="157" text="no interface constructor-execution join point - use java.util.List+ for implementing classes [Xlint:noInterfaceCtorJoinpoint]">
+ </message>
+ </compile>
+ </ajc-test>
+
\ No newline at end of file