summaryrefslogtreecommitdiffstats
path: root/tests/java5/annotations/binding/BindingWithAnnotatedItds2.aj
blob: f7cee7baa9ea08d68c4f7951f13fbbb44187677f (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
// Annotated ITD (field) being matched upon and extracted
import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}

public aspect BindingWithAnnotatedItds2 {

  @Fruit("banana") int A.i;
 
  public @Fruit("apple") String A.j;

  private @Fruit("orange") int[] A.k;
  
  public static void main(String[]argv) {
    A a = new A();
    a.i = 5;
    a.j = "hello";
    a.k = new int[]{1,2,3};
  }
  
}

class A { }

aspect X {

  before(Fruit f): set(* *) && @annotation(f) {
    System.err.println("Found "+f.value()+" at jp "+thisJoinPoint+
                       " ("+thisJoinPoint.getSourceLocation()+")");
  }

  //before(Fruit f): execution(* *(..)) && @annotation(f) {
  //  System.err.println("Execution of something fruity at this jp"+thisJoinPoint+
  //    " ("+thisJoinPoint.getSourceLocation()+")");
  //}
  
}