aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndy Clement <aclement@gopivotal.com>2013-10-01 10:00:14 -0700
committerAndy Clement <aclement@gopivotal.com>2013-10-01 10:00:14 -0700
commit2393befbdf0ef3842b838591f7af08e7d1467e34 (patch)
tree52d5234db2b09a769ca61d8a7611afc513bf70f3 /tests
parente51636db502218e63f3125b59087de93dd299c73 (diff)
downloadaspectj-2393befbdf0ef3842b838591f7af08e7d1467e34.tar.gz
aspectj-2393befbdf0ef3842b838591f7af08e7d1467e34.zip
418129: annos on top most implementor method
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs174/pr418129/Target.java27
-rw-r--r--tests/bugs174/pr418129/Target2.java27
-rw-r--r--tests/bugs174/pr418129/Target3.java27
-rw-r--r--tests/bugs174/pr418129/Target4.java25
-rw-r--r--tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java16
-rw-r--r--tests/src/org/aspectj/systemtest/ajc174/ajc174.xml61
6 files changed, 183 insertions, 0 deletions
diff --git a/tests/bugs174/pr418129/Target.java b/tests/bugs174/pr418129/Target.java
new file mode 100644
index 000000000..a3d1b2e97
--- /dev/null
+++ b/tests/bugs174/pr418129/Target.java
@@ -0,0 +1,27 @@
+import java.lang.annotation.*;
+
+interface Behavior {
+String hello();
+}
+
+aspect Trait {
+ // public String Behavior.name;
+
+ public String Behavior.hello() {
+ return "hello";
+ }
+}
+
+public class Target implements Behavior {
+ public static aspect A {
+// declare @field: * Target.name: @Tagged; // NO WORKY
+ declare @method: * Target.hello(..): @Tagged; // NO WORKY
+ }
+
+ public static void main(String []argv) throws Exception {
+ System.out.println(Target.class.getDeclaredMethod("hello").getDeclaredAnnotations()[0]);
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Tagged {}
diff --git a/tests/bugs174/pr418129/Target2.java b/tests/bugs174/pr418129/Target2.java
new file mode 100644
index 000000000..cc8b9e839
--- /dev/null
+++ b/tests/bugs174/pr418129/Target2.java
@@ -0,0 +1,27 @@
+import java.lang.annotation.*;
+
+interface Behavior {
+ String hello();
+}
+
+aspect Trait {
+// public String Behavior.name;
+
+ public String Behavior.hello() throws java.io.IOException {
+ return "hello";
+ }
+}
+
+public class Target2 implements Behavior {
+ public static aspect A {
+// declare @field: * Target2.name: @Tagged; // NO WORKY
+ declare @method: * Target2.hello(..): @Tagged; // NO WORKY
+ }
+
+ public static void main(String []argv) throws Exception {
+ System.out.println(Target2.class.getDeclaredMethod("hello").getDeclaredAnnotations()[0]);
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Tagged {}
diff --git a/tests/bugs174/pr418129/Target3.java b/tests/bugs174/pr418129/Target3.java
new file mode 100644
index 000000000..cba868929
--- /dev/null
+++ b/tests/bugs174/pr418129/Target3.java
@@ -0,0 +1,27 @@
+import java.lang.annotation.*;
+
+interface Behavior {
+ String hello();
+}
+
+aspect Trait {
+ @Wibble
+ public String Behavior.hello() throws java.io.IOException {
+ return "hello";
+ }
+}
+
+public class Target3 implements Behavior {
+ public static aspect A {
+ declare @method: * Target3.hello(..): @Tagged;
+ }
+
+ public static void main(String []argv) throws Exception {
+ System.out.println(Target3.class.getDeclaredMethod("hello").getDeclaredAnnotations().length);
+ System.out.println(Target3.class.getDeclaredMethod("hello").getDeclaredAnnotations()[0]);
+ System.out.println(Target3.class.getDeclaredMethod("hello").getDeclaredAnnotations()[1]);
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Tagged {}
+@Retention(RetentionPolicy.RUNTIME) @interface Wibble {}
diff --git a/tests/bugs174/pr418129/Target4.java b/tests/bugs174/pr418129/Target4.java
new file mode 100644
index 000000000..4bae09c1f
--- /dev/null
+++ b/tests/bugs174/pr418129/Target4.java
@@ -0,0 +1,25 @@
+import java.lang.annotation.*;
+
+interface Behavior {
+ String hello();
+}
+
+aspect Trait {
+ @Tagged(31)
+ public String Behavior.hello() throws java.io.IOException {
+ return "hello";
+ }
+}
+
+public class Target4 implements Behavior {
+ public static aspect A {
+ declare @method: * Target4.hello(..): @Tagged;
+ }
+
+ public static void main(String []argv) throws Exception {
+ System.out.println(Target4.class.getDeclaredMethod("hello").getDeclaredAnnotations().length);
+ System.out.println(Target4.class.getDeclaredMethod("hello").getDeclaredAnnotations()[0]);
+ }
+}
+
+@Retention(RetentionPolicy.RUNTIME) @interface Tagged { int value() default 42;}
diff --git a/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java b/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java
index 06af6a53b..1e300dd0a 100644
--- a/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java
+++ b/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java
@@ -21,6 +21,22 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
*/
public class Ajc174Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+ public void testAnnotatedItd_418129() throws Exception {
+ runTest("annotated itd");
+ }
+
+ public void testAnnotatedItd_418129_2() throws Exception {
+ runTest("annotated itd 2");
+ }
+
+ public void testAnnotatedItd_418129_3() throws Exception {
+ runTest("annotated itd 3");
+ }
+
+ public void testAnnotatedItd_418129_4() throws Exception {
+ runTest("annotated itd 4");
+ }
+
public void testSuperItdCtor_413378() throws Exception {
runTest("super itd ctor");
}
diff --git a/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml b/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml
index 85ff2af8b..5b47cf4d3 100644
--- a/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml
+++ b/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml
@@ -2,6 +2,67 @@
<suite>
+ <ajc-test dir="bugs174/pr418129" title="annotated itd">
+ <compile files="Target.java" options="-1.5 -showWeaveInfo">
+ <message kind="weave" text="Type 'Behavior' (Target.java) has intertyped method from 'Trait' (Target.java:'java.lang.String Behavior.hello()')"/>
+ <message kind="weave" text="Type 'Target' (Target.java) has intertyped method from 'Trait' (Target.java:'java.lang.String Behavior.hello()')"/>
+ <message kind="weave" text="'public java.lang.String Target.hello()' (Target.java) is annotated with @Tagged method annotation from 'Target$A' (Target.java:18)"/>
+ </compile>
+ <run class="Target">
+ <stdout>
+ <line text="@Tagged()"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <!-- declared with throws exception -->
+ <ajc-test dir="bugs174/pr418129" title="annotated itd 2">
+ <compile files="Target2.java" options="-1.5 -showWeaveInfo">
+ <message kind="weave" text="Type 'Behavior' (Target2.java) has intertyped method from 'Trait' (Target2.java:'java.lang.String Behavior.hello()')"/>
+ <message kind="weave" text="Type 'Target2' (Target2.java) has intertyped method from 'Trait' (Target2.java:'java.lang.String Behavior.hello()')"/>
+ <message kind="weave" text="'public java.lang.String Target2.hello()' (Target2.java) is annotated with @Tagged method annotation from 'Target2$A' (Target2.java:18)"/>
+ </compile>
+ <run class="Target2">
+ <stdout>
+ <line text="@Tagged()"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <!-- already annotated with another annotation -->
+ <ajc-test dir="bugs174/pr418129" title="annotated itd 3">
+ <compile files="Target3.java" options="-1.5 -showWeaveInfo">
+ <message kind="weave" text="Type 'Behavior' (Target3.java) has intertyped method from 'Trait' (Target3.java:'java.lang.String Behavior.hello()')"/>
+ <message kind="weave" text="Type 'Target3' (Target3.java) has intertyped method from 'Trait' (Target3.java:'java.lang.String Behavior.hello()')"/>
+ <message kind="weave" text="'public java.lang.String Target3.hello()' (Target3.java) is annotated with @Tagged method annotation from 'Target3$A' (Target3.java:16)"/>
+ </compile>
+ <run class="Target3">
+ <stdout>
+ <line text="2"/>
+ <line text="@Wibble()"/>
+ <line text="@Tagged()"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
+ <!-- already annotated with the same annotation -->
+ <ajc-test dir="bugs174/pr418129" title="annotated itd 4">
+ <compile files="Target4.java" options="-1.5 -showWeaveInfo">
+ <message kind="weave" text="Type 'Behavior' (Target4.java) has intertyped method from 'Trait' (Target4.java:'java.lang.String Behavior.hello()')"/>
+ <message kind="weave" text="Type 'Target4' (Target4.java) has intertyped method from 'Trait' (Target4.java:'java.lang.String Behavior.hello()')"/>
+ <!-- warning turned off as it gets confusing - when the itd on the interface is hit by a deca -->
+ <!--
+ <message kind="warning" text="java.lang.String Target4.hello() - already has an annotation of type Tagged, cannot add a second instance [Xlint:elementAlreadyAnnotated]"/>
+ -->
+ </compile>
+ <run class="Target4">
+ <stdout>
+ <line text="1"/>
+ <line text="@Tagged(value=31)"/>
+ </stdout>
+ </run>
+ </ajc-test>
+
<ajc-test dir="bugs174/pr413378" title="super itd ctor">
<compile files="Code.java" options="-1.5 -showWeaveInfo">
<message kind="weave" text="Type 'Child' (Code.java) has intertyped constructor from 'MyTest' (Code.java:'void Child.&lt;init&gt;(java.lang.String, int)')"/>