summaryrefslogtreecommitdiffstats
path: root/tests/features1611/declareMinus/OnOff.java
blob: 479359b355513699f77b58633aa608f6e00d36ed (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
import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME)
@interface Anno {}

aspect Foo {
  // one way round
  declare @field: * OnOff.field: -@Anno;
  declare @field: * OnOff.field: @Anno;

  // the other way round
  declare @field: * OnOff.field2: @Anno;
  declare @field: * OnOff.field2: -@Anno;
}

public class OnOff {

  public static int field;

  public int field2;

  public static void main(String[]argv) throws Exception {
    Object o = OnOff.class.getDeclaredField("field").getAnnotation(Anno.class);
    System.out.println("field annotated? "+(o==null?"no":"yes"));

    o = OnOff.class.getDeclaredField("field2").getAnnotation(Anno.class);
    System.out.println("field2 annotated? "+(o==null?"no":"yes"));
  }
}