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.

A8.java 817B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Bind the this on a call and change it with proceed... works
  2. import org.aspectj.lang.ProceedingJoinPoint;
  3. import org.aspectj.lang.annotation.*;
  4. @Aspect
  5. public class A8 {
  6. M newM = new M("2");
  7. @Around("execution(void M.method(String)) && args(p) && this(t)")
  8. public void a( ProceedingJoinPoint pjp, String p, M t) throws Throwable {
  9. System.err.println("advice from ataj aspect");
  10. pjp.proceed(new Object[]{newM,"faked"});
  11. }
  12. public static void main(String []argv) {
  13. M.main(argv);
  14. }
  15. }
  16. class M {
  17. String prefix;
  18. public M(String prefix) { this.prefix = prefix; }
  19. public static void main( String[] args ) {
  20. M m = new M("1");
  21. m.methodCaller("real");
  22. }
  23. public void methodCaller(String param) {
  24. method(param);
  25. }
  26. public void method(String s) { System.err.println(prefix+s); }
  27. }