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.

AnnotationAspect.java 815B

123456789101112131415161718192021222324252627282930
  1. import java.lang.annotation.*;
  2. @Retention(RetentionPolicy.RUNTIME)
  3. @Target(ElementType.TYPE)
  4. @interface TestAnnotation1 {}
  5. @Retention(RetentionPolicy.RUNTIME)
  6. @Target(ElementType.TYPE)
  7. @interface TestAnnotation2{}
  8. @TestAnnotation1
  9. class Annotated {}
  10. interface Marker {}
  11. public aspect AnnotationAspect {
  12. declare @type: @TestAnnotation1 *: @TestAnnotation2;
  13. // of cource this matches
  14. // declare parents: (@TestAnnotation1 *) implements Marker;
  15. // this matches, too
  16. // declare parents: (@TestAnnotation2 *) implements Marker;
  17. // this does not match on Annotated
  18. declare parents: (@TestAnnotation2 *) && !java.lang.annotation.Annotation implements Marker;
  19. // but this does match on annotated
  20. // declare parents: (@TestAnnotation1 *) && !java.lang.annotation.Annotation implements Marker;
  21. }