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 628B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import org.aspectj.testing.Tester;
  2. // PR#297 anonymous inner class with aspect
  3. public class Driver {
  4. public static String s = "";
  5. public static void main(String[] args){
  6. new Test().go();
  7. Tester.checkEqual(s, "-bar-after", "");
  8. }
  9. }
  10. class Test {
  11. void go(){
  12. seto( new I(){
  13. public void foo(){ bar(); }
  14. });
  15. o.foo();
  16. }
  17. void bar(){
  18. Driver.s += "-bar";
  19. }
  20. I o;
  21. void seto(I o){
  22. this.o = o;
  23. }
  24. }
  25. interface I { void foo(); }
  26. aspect A {
  27. void around(): this(I) && target(Test) && within(Test) && call(* bar()){
  28. proceed();
  29. Driver.s += "-after";
  30. }
  31. }