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.

AnnotationDeclaringType.java 803B

1234567891011121314151617181920212223242526272829
  1. import java.lang.annotation.Target;
  2. import java.lang.annotation.ElementType;
  3. @Target({ElementType.TYPE})
  4. @interface TypeAnnotation{}
  5. @Target({ElementType.METHOD})
  6. @interface MethodAnnotation{}
  7. @TypeAnnotation
  8. public class AnnotationDeclaringType {
  9. public void method1() {
  10. }
  11. }
  12. aspect A {
  13. // matches the execution of any method where the declaring type
  14. // has the @TypeAnnotation - should compile ok and get no xlint errors
  15. pointcut pc() : execution(* (@TypeAnnotation *).*(..));
  16. declare warning : pc() : "* (@TypeAnnotation *).*(..)";
  17. // should get an xlint warning because declaring types can only
  18. // have the default @Target or @Target{ElementType.TYPE} target
  19. pointcut pc2() : execution(* (@MethodAnnotation *).*(..));
  20. declare warning : pc2() : "* (@MethodAnnotation *).*(..)";
  21. }