summaryrefslogtreecommitdiffstats
path: root/tests/java5/annotations/declare/EnumAndClassValues.aj
blob: 9090a0154931b504ab3120941610f2c192a83430 (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
import java.lang.annotation.*;

enum SimpleEnum { Red,Orange,Yellow,Green,Blue,Indigo,Violet };

@Retention(RetentionPolicy.RUNTIME)
@interface AnnotationEnumElement {
  SimpleEnum enumval();
}

@Retention(RetentionPolicy.RUNTIME)
@interface AnnotationClassElement {
  Class clz();
}


aspect AnnotatedWithEnumClass {
  declare @type: FunkyAnnotations : @AnnotationEnumElement(enumval=SimpleEnum.Red);
  declare @type: FunkyAnnotations : @AnnotationClassElement(clz=Integer.class);

  before(AnnotationEnumElement aee): call(* *(..)) && @target(aee) {
    System.err.println("advice running: "+aee.enumval());
  }

  before(AnnotationClassElement ace): call(* *(..)) && @target(ace) {
    System.err.println("advice running: "+ace.clz());
  }
}