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.

Driver.java 795B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import org.aspectj.testing.Tester;
  2. import java.util.*;
  3. // PR#304 lookup rules for unqualified pointcut names
  4. public class Driver {
  5. public static String s = "";
  6. public static void main(String[] args){
  7. new MyObject().go();
  8. Tester.checkEqual(s, "-before-new", "");
  9. }
  10. }
  11. aspect MyPointCuts {
  12. pointcut excludes():
  13. (call(* equals(..))) ||
  14. (call(* toString(..))) ||
  15. (call(* hashCode(..))) ||
  16. (call(* clone(..)))
  17. ;
  18. pointcut allCalls(): call(* *(..)) && !excludes();
  19. }
  20. aspect MyAspect /*of eachobject(instanceof(MyObject))*/ {
  21. before(): MyPointCuts.allCalls() && target(MyObject) {
  22. Driver.s += "-before";
  23. }
  24. }
  25. class MyObject {
  26. public void go() {
  27. Driver.s += "-new";
  28. }
  29. }