summaryrefslogtreecommitdiffstats
path: root/tests/bugs169/pr287613/Decaf1.java
blob: c4e5a64aee7fc662994af1521cd6e972311c27e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
}