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.

AdviceFormalsCp.java 977B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import org.aspectj.testing.Tester;
  2. /**
  3. * PR#544 the formals passed to advice should behave just like
  4. * any other method formal
  5. */
  6. public class AdviceFormalsCp {
  7. public static void main(String[] args) {
  8. Tester.checkEqual(new C().m("bye"), "foo");
  9. Tester.checkEqual(new C().mi(2.), 1);
  10. }
  11. }
  12. class C {
  13. public String m(Object p) {
  14. return "foo";
  15. }
  16. public int mi(double p) {
  17. return 1;
  18. }
  19. }
  20. aspect A {
  21. after(Object p) returning(Object o): call(* C.m*(*)) && args(p) {
  22. p = Boolean.TRUE;
  23. o = Boolean.TRUE;
  24. Tester.checkEqual(p, Boolean.TRUE);
  25. Tester.checkEqual(o, Boolean.TRUE);
  26. }
  27. Object around(Object p, Object o): call(* C.m*(*)) && args(p) && target(o) {
  28. Object ret = proceed(p, o);
  29. p = Boolean.TRUE;
  30. o = Boolean.TRUE;
  31. Tester.checkEqual(p, Boolean.TRUE);
  32. Tester.checkEqual(o, Boolean.TRUE);
  33. return ret;
  34. }
  35. }