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.

CflowCycles.java 1015B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import org.aspectj.testing.Tester;
  2. /** @testcase cflow cycles in advice from different aspects */
  3. public class CflowCycles {
  4. public static void main( String args[] ) {
  5. Tester.expectEvent("target A1");
  6. Tester.expectEvent("target A2");
  7. new Target().run();
  8. Tester.checkAllEventsIgnoreDups();
  9. }
  10. }
  11. class Target {
  12. public void run(){ }
  13. }
  14. aspect A1 {
  15. pointcut TargetRunFlow ()
  16. // ok if no cflow: within(Target) && execution(* *(..)) && !within(A1+);
  17. : !within(A1+) && !preinitialization(new(..)) && !initialization(new(..))//cflow(within(Target) && execution(* *(..))) && !within(A1+)
  18. ;
  19. Object around () : TargetRunFlow() {
  20. Tester.event("target A1");
  21. return proceed();
  22. }
  23. // ok if in the same class
  24. }
  25. aspect A2 {
  26. pointcut TargetRun ()
  27. : within(Target) && execution(* *(..)) && !within(A2+);
  28. ;
  29. Object around () : TargetRun() {
  30. Tester.event("target A2");
  31. return proceed();
  32. }
  33. }