diff options
author | aclement <aclement> | 2010-06-18 22:11:06 +0000 |
---|---|---|
committer | aclement <aclement> | 2010-06-18 22:11:06 +0000 |
commit | 98cb0219ae1990d3dca3b4bdc654d342f224b232 (patch) | |
tree | e0b827a4e9f50c93fe80b09ae2e04ee304df2f33 /tests/bugs169/pr287613/Decaf1.java | |
parent | d42a8436ab49b85b446b6bb13434719c96088c47 (diff) | |
download | aspectj-98cb0219ae1990d3dca3b4bdc654d342f224b232.tar.gz aspectj-98cb0219ae1990d3dca3b4bdc654d342f224b232.zip |
287613/315820: testcode
Diffstat (limited to 'tests/bugs169/pr287613/Decaf1.java')
-rw-r--r-- | tests/bugs169/pr287613/Decaf1.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/bugs169/pr287613/Decaf1.java b/tests/bugs169/pr287613/Decaf1.java new file mode 100644 index 000000000..c4e5a64ae --- /dev/null +++ b/tests/bugs169/pr287613/Decaf1.java @@ -0,0 +1,53 @@ +import java.lang.annotation.*; +import java.lang.reflect.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface Annot1 {} +@Retention(RetentionPolicy.RUNTIME) +@interface Annot2 {} +@Retention(RetentionPolicy.RUNTIME) +@interface Annot3 {} + +class Target { + public static void main(String[] argv) throws Exception { + System.out.println("Field one"); + printAnnotations(A.class.getDeclaredField("one")); + printAnnotations(B.class.getDeclaredField("one")); + System.out.println("Field two"); + printAnnotations(A.class.getDeclaredField("two")); + printAnnotations(B.class.getDeclaredField("two")); + System.out.println("Field three"); + printAnnotations(A.class.getDeclaredField("two")); + printAnnotations(B.class.getDeclaredField("two")); + } + + public static void printAnnotations(Field field) { + Annotation[] annos = field.getAnnotations(); + if (annos==null || annos.length==0) { + System.out.println("no annotations"); + } else { + for (Annotation anno: annos) { + System.out.print(anno+" "); + } + System.out.println(); + } + } +} + +class A { + public int one; + public String two; + public float three; +} + +class B { + public int one; + public String two; + public float three; +} + +aspect DeclareAnnot { + declare @field: (int A.one) || (int B.one): @Annot1; + declare @field: (String two) && !(* B.*): @Annot2; + declare @field: !(* one) && !(* two): @Annot3; +} |