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.

AdviceOnIntroduced.java 596B

1234567891011121314151617181920212223242526
  1. import org.aspectj.testing.Tester;
  2. public aspect AdviceOnIntroduced {
  3. public static void main(String[] args) { test(); }
  4. public static void test() {
  5. Tester.checkEqual(new Foo(10).foo(5), 6, "foo");
  6. }
  7. int Foo.foo(int n) { return n; }
  8. Foo.new(int w) { this(); }
  9. int around(int n):
  10. within(AdviceOnIntroduced) &&
  11. (args(n) && execution(int foo(int))) {
  12. int result = proceed(n);
  13. return result+1;
  14. }
  15. before(): within(Foo) && execution(new(..)) {
  16. //System.out.println("before new");
  17. }
  18. }
  19. class Foo {
  20. }