aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoraclement <aclement>2005-02-11 09:18:37 +0000
committeraclement <aclement>2005-02-11 09:18:37 +0000
commita3a53137d5acff4fce60b49c976acb6d7904e888 (patch)
treecfae21af7234c9a2f0ab5c776873b57fe2634933 /tests
parent698ad9633f9ba28a8e5ebfbd219a4c4028e4f997 (diff)
downloadaspectj-a3a53137d5acff4fce60b49c976acb6d7904e888.tar.gz
aspectj-a3a53137d5acff4fce60b49c976acb6d7904e888.zip
Tests for 2 new annotation bugs: (1) Using the pattern '@Annotation *' in declare parents wasn't working (2) Using an annotation without importing it was causing the compiler to go bang.
Diffstat (limited to 'tests')
-rw-r--r--tests/java5/annotations/binding/complexExample/A.java2
-rw-r--r--tests/java5/annotations/binding/complexExample/C.java13
-rw-r--r--tests/java5/annotations/binding/complexExample/X3.java9
-rw-r--r--tests/java5/annotations/binding/complexExample/X4.java10
-rw-r--r--tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java21
5 files changed, 55 insertions, 0 deletions
diff --git a/tests/java5/annotations/binding/complexExample/A.java b/tests/java5/annotations/binding/complexExample/A.java
index 92ffd35af..40a220538 100644
--- a/tests/java5/annotations/binding/complexExample/A.java
+++ b/tests/java5/annotations/binding/complexExample/A.java
@@ -7,6 +7,8 @@ public class A {
public static void main(String []argv) {
new A().a();
new B().b();
+ if ((new A()) instanceof java.io.Serializable)
+ throw new RuntimeException("A should never be serializable");
}
@Color("blue")
diff --git a/tests/java5/annotations/binding/complexExample/C.java b/tests/java5/annotations/binding/complexExample/C.java
new file mode 100644
index 000000000..8d8827ba9
--- /dev/null
+++ b/tests/java5/annotations/binding/complexExample/C.java
@@ -0,0 +1,13 @@
+package g.h.i;
+import d.e.f.*;
+
+@Color("black")
+public class C {
+
+ public static void main(String []argv) {
+ if (!(new C() instanceof java.io.Serializable))
+ throw new RuntimeException("C should be serializable, done via decp");
+ }
+
+ public void c() { System.err.println("g.h.i.C.c running");}
+}
diff --git a/tests/java5/annotations/binding/complexExample/X3.java b/tests/java5/annotations/binding/complexExample/X3.java
new file mode 100644
index 000000000..ab72a98dc
--- /dev/null
+++ b/tests/java5/annotations/binding/complexExample/X3.java
@@ -0,0 +1,9 @@
+import a.b.c.A;
+
+import d.e.f.*;
+
+public aspect X3 {
+
+ declare parents: @Color * implements java.io.Serializable;
+
+}
diff --git a/tests/java5/annotations/binding/complexExample/X4.java b/tests/java5/annotations/binding/complexExample/X4.java
new file mode 100644
index 000000000..edfb63ef1
--- /dev/null
+++ b/tests/java5/annotations/binding/complexExample/X4.java
@@ -0,0 +1,10 @@
+import a.b.c.A;
+
+public aspect X4 {
+
+ // Error as Color not imported
+ before(A a): execution(@Color * A+.*(..)) && this(a) {
+ System.err.println("Before call to "+thisJoinPoint);
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java
index 61b704667..cf2987a70 100644
--- a/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java
+++ b/tests/src/org/aspectj/systemtest/ajc150/AnnotationBinding.java
@@ -11,6 +11,8 @@
package org.aspectj.systemtest.ajc150;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
import org.aspectj.tools.ajc.CompilationResult;
@@ -307,6 +309,25 @@ public class AnnotationBinding extends TestUtils {
RunResult rR = run("a.b.c.A");
}
+ // declare parents: @Color * implements Serializable
+ public void testDeclareParentsWithAnnotatedAnyPattern() {
+ CompilationResult cR = ajc(new File(baseDir,"complexExample"),
+ new String[]{"A.java","B.java","C.java","Color.java","X3.java","-1.5","-d","."});
+ assertMessages(cR,new EmptyMessageSpec());
+ RunResult rR = run("g.h.i.C"); // C should now be serializable
+ rR = run("a.b.c.A"); // A should not be serializable
+ }
+
+ // Should error (in a nice way!) on usage of an annotation that isnt imported
+ public void testAnnotationUsedButNotImported() {
+ CompilationResult cR = ajc(new File(baseDir,"complexExample"),
+ new String[]{"A.java","B.java","Color.java","X4.java","-1.5","-d","."});
+ List warnings = new ArrayList();
+ warnings.add(new Message(6));
+ assertMessages(cR,new MessageSpec(warnings,null));
+ RunResult rR = run("a.b.c.A");
+ }
+
// Binding with calls/executions of static methods
public void testCallsAndExecutionsOfStaticMethods() {
CompilationResult cR = ajc(baseDir,new String[]{"StaticMethods.java","-1.5","-d","."});