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.

Two.java 505B

123456789101112131415161718192021222324252627
  1. public class Two {
  2. public static void main(String[] argv) {
  3. Two a = new Two();
  4. a.m();
  5. a.m();
  6. a.m();
  7. a.m();
  8. }
  9. public void m() {
  10. System.out.println("Method m() running");
  11. }
  12. }
  13. aspect X {
  14. int count = 0;
  15. boolean doit() {
  16. count++;
  17. System.out.println("In instance check method, count="+count+" so doit returns "+((count%2)==0));
  18. return (count%2)==0;
  19. }
  20. before():call(* m(..)) && if(thisAspectInstance.doit()){
  21. System.out.println("In advice()");
  22. }
  23. }