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.

CFlowObjects.java 826B

1234567891011121314151617181920212223242526272829303132333435
  1. import org.aspectj.testing.Tester;
  2. public class CFlowObjects {
  3. public static void main(String[] args){
  4. new Test().go();
  5. Tester.checkEqual(Test.cflowObjects, 1, "1st cflow");
  6. Tester.checkEqual(Test.callsPerCFlow, 1, "1 call for each cflow");
  7. new Test().go();
  8. Tester.checkEqual(Test.cflowObjects, 2, "2nd cflow");
  9. Tester.checkEqual(Test.callsPerCFlow, 1, "1 call for each cflow");
  10. }
  11. }
  12. class Test {
  13. static int cflowObjects = 0;
  14. static int callsPerCFlow = 0;
  15. void go(){
  16. foo();
  17. }
  18. void foo(){}
  19. }
  20. aspect A percflow(target(Test) && call(void go())) {
  21. { Test.cflowObjects++; }
  22. { Test.callsPerCFlow = 0; }
  23. //before(): instanceof(Test) && calls(void Object.*()){ Test.callsPerCFlow++; }
  24. before(): within(Test) && call(void Object+.*(..)) {
  25. Test.callsPerCFlow++;
  26. }
  27. }