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.

A.aj 682B

12345678910111213141516171819202122232425262728293031
  1. import static java.lang.annotation.RetentionPolicy.RUNTIME;
  2. import java.lang.annotation.*;
  3. @Retention(RUNTIME)
  4. @Inherited
  5. @interface MyAnnotation {}
  6. public aspect A perthis(annotatedClasses()) {
  7. pointcut annotatedClasses() : @this(MyAnnotation);
  8. before(): initialization(*.new(..)) {System.err.println(thisJoinPoint.getSignature().getDeclaringType()); }
  9. public static void main(String []argv) {
  10. new Foo();
  11. new Goo();
  12. new Boo();
  13. new Soo();
  14. }
  15. }
  16. // yes/no indicates if runtime match expected for staticinitialization
  17. @MyAnnotation class Foo { } // YES
  18. class Goo { } // NO
  19. @MyAnnotation class Boo { } // YES
  20. class Soo extends Boo { } // YES