summaryrefslogtreecommitdiffstats
path: root/tests/java5/annotations/declare/atfield/WrongTarget.aj
blob: f82eae4b893c10eb241a6183923aae33766a9062 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// trying to put wrong annotations onto a field
import java.lang.annotation.*;

@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @interface MethodColoring { String value(); }
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)   @interface TypeColoring   { String value(); }

public aspect WrongTarget {
  declare @field: public int * : @MethodColoring("red");
  declare @field: public int * : @TypeColoring("blue");
}

aspect X {
  before(): set(@MethodColoring * *) {
    System.err.println("Colored field access at "+thisJoinPoint);
  }
  before(): set(@TypeColoring * *) {
    System.err.println("Colored field access at "+thisJoinPoint);
  }
}