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

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

public aspect BindingWithDeclaredAnnotationItds3 {

  int A.i;

  public static void main(String[]argv) {
    A a = new A();
    a.i = 5;
  }
  
}

class A { }

aspect X {

  declare @field: int A.i: @Fruit("orange");
  declare @field: int A.i: @Drink("margarita");

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

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

  
}