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.

Aoriginal.java 898B

12345678910111213141516171819202122232425262728293031
  1. import java.lang.annotation.*;
  2. @Retention(RetentionPolicy.RUNTIME) @interface Ann {}
  3. aspect Aspect {
  4. // Call to an annotated method
  5. pointcut annotated(Ann b) : call(@Ann * *(..)) && @annotation(b);
  6. // Top level call to an annotated method
  7. pointcut annotatedTop(Ann b) : annotated(b) && !cflowbelow(annotated(Ann));
  8. // Non top level call
  9. pointcut annotatedNotTop(Ann b, Ann bTopo) :
  10. annotated(b) && cflowbelow(annotatedTop(bTopo));
  11. //before(Ann b, Ann bTopo) : annotatedNotTop(b, bTopo) {
  12. before() : call(@Ann * *(..)) { //(b, bTopo) {
  13. System.out.println("\tJoin point: " + thisJoinPointStaticPart);
  14. }
  15. // Methods with out the Ann annotation but in an Ann annotated type get Ann
  16. declare @method: !@Ann * (@Ann *).*(..) : @Ann;
  17. }
  18. public class A {
  19. void foo() { new B().foo(); /*new B().goo();*/}
  20. public static void main(String[] args) { new A().foo(); }
  21. }