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.

Code4.java 727B

1234567891011121314151617181920212223242526272829303132333435
  1. import org.aspectj.lang.annotation.*;
  2. import org.aspectj.lang.*;
  3. public aspect Code4 {
  4. void around(Foo targeto, String s): call(* Foo.run(String)) && args(s) && target(targeto) {
  5. System.out.println("first: binding target, just passing everything through");
  6. proceed(targeto, s);
  7. }
  8. public static void main(String []argv) {
  9. new Foo(0).execute();
  10. }
  11. }
  12. class Foo {
  13. int i;
  14. public Foo(int i) {
  15. this.i = i;
  16. }
  17. public void execute() {
  18. Foo f1 = new Foo(1);
  19. Foo f2 = new Foo(2);
  20. f1.run("abc");
  21. }
  22. public void run(String s) {
  23. System.out.println("Executing run("+s+") on "+this.toString());
  24. }
  25. public String toString() {
  26. return ("Foo(i="+i+")");
  27. }
  28. }