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.

BugCase2.java 619B

12345678910111213141516171819202122232425262728293031
  1. import org.aspectj.lang.*;
  2. import org.aspectj.lang.annotation.*;
  3. @Aspect
  4. public class BugCase2 {
  5. @Pointcut("execution(* setAge(..)) && args(i)")
  6. void setAge(int i) {}
  7. @Around("setAge(i)")
  8. public Object twiceAsOld(ProceedingJoinPoint thisJoinPoint, int i) {
  9. System.err.println("advice running");
  10. return thisJoinPoint.proceed(new Object[]{i*2});
  11. }
  12. public static void main(String []argv) {
  13. Foo.main(argv);
  14. }
  15. }
  16. class Foo {
  17. int a;
  18. public void setAge(int i) {
  19. System.err.println("Setting age to "+i);
  20. a=i;
  21. }
  22. public static void main(String[]argv) {
  23. new Foo().setAge(5);
  24. }
  25. }