diff options
author | aclement <aclement> | 2005-11-08 12:13:05 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-11-08 12:13:05 +0000 |
commit | d9757d7c41bf2661455422ce3234e4794c9f533e (patch) | |
tree | ba4352377521fb1e27930948371577505b5a6d71 /tests/bugs150/pr114005 | |
parent | 9905334cb7e47e8c0fc78d624e0f8c06cd79baee (diff) | |
download | aspectj-d9757d7c41bf2661455422ce3234e4794c9f533e.tar.gz aspectj-d9757d7c41bf2661455422ce3234e4794c9f533e.zip |
testcode and fix for pr114005: copying annotations to ITDfs on interfaces.
Diffstat (limited to 'tests/bugs150/pr114005')
-rw-r--r-- | tests/bugs150/pr114005/Declaration1.java | 32 | ||||
-rw-r--r-- | tests/bugs150/pr114005/Declaration2.java | 32 |
2 files changed, 64 insertions, 0 deletions
diff --git a/tests/bugs150/pr114005/Declaration1.java b/tests/bugs150/pr114005/Declaration1.java new file mode 100644 index 000000000..787be727b --- /dev/null +++ b/tests/bugs150/pr114005/Declaration1.java @@ -0,0 +1,32 @@ +import java.lang.annotation.*; +import java.lang.reflect.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface SampleAnnotation { } + +interface TestInterface { } + +class Test implements TestInterface{} + +// First case: the ITD on the interface is annotated, it should make it through +// to the member added to the implementor +public aspect Declaration1 { + + // ITD directly on the implementor + @SampleAnnotation + public String Test.firstProperty; + + // ITD on the interface + @SampleAnnotation + public String TestInterface.secondProperty; + + public static void main(String[] args) { + for (Field field: Test.class.getFields()) { + StringBuffer sb = new StringBuffer(); + sb.append(field.toString()); + boolean b = field.isAnnotationPresent(SampleAnnotation.class); + sb.append(" has annotation:").append(b); + System.out.println(sb.toString()); + } + } +}
\ No newline at end of file diff --git a/tests/bugs150/pr114005/Declaration2.java b/tests/bugs150/pr114005/Declaration2.java new file mode 100644 index 000000000..0e0b959c5 --- /dev/null +++ b/tests/bugs150/pr114005/Declaration2.java @@ -0,0 +1,32 @@ +import java.lang.annotation.*; +import java.lang.reflect.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface SampleAnnotation { } + +interface TestInterface { } + +class Test implements TestInterface{} + +// Second case: the ITD is annotated via a declare @field. +public aspect Declaration2 { + + declare @field: * TestInterface.secondProperty: @SampleAnnotation; + + // ITD directly on the implementor + @SampleAnnotation + public String Test.firstProperty; + + // ITD on the interface + public String TestInterface.secondProperty; + + public static void main(String[] args) { + for (Field field: Test.class.getFields()) { + StringBuffer sb = new StringBuffer(); + sb.append(field.toString()); + boolean b = field.isAnnotationPresent(SampleAnnotation.class); + sb.append(" has annotation:").append(b); + System.out.println(sb.toString()); + } + } +}
\ No newline at end of file |