You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BindingWithDeclaredAnnotationItds3.aj 895B

123456789101112131415161718192021222324252627282930313233343536
  1. // Annotated ITD (field) being matched upon and extracted
  2. import java.lang.annotation.*;
  3. @Retention(RetentionPolicy.RUNTIME) @interface Fruit { String value();}
  4. @Retention(RetentionPolicy.RUNTIME) @interface Drink { String value();}
  5. public aspect BindingWithDeclaredAnnotationItds3 {
  6. int A.i;
  7. public static void main(String[]argv) {
  8. A a = new A();
  9. a.i = 5;
  10. }
  11. }
  12. class A { }
  13. aspect X {
  14. declare @field: int A.i: @Fruit("orange");
  15. declare @field: int A.i: @Drink("margarita");
  16. before(Fruit f): set(* *) && @annotation(f) {
  17. System.err.println("Found fruit "+f.value()+" at jp "+thisJoinPoint+
  18. " ("+thisJoinPoint.getSourceLocation()+")");
  19. }
  20. before(Drink d): set(* *) && @annotation(d) {
  21. System.err.println("Found drink "+d.value()+" at jp "+thisJoinPoint+
  22. " ("+thisJoinPoint.getSourceLocation()+")");
  23. }
  24. }