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

12345678910111213141516171819202122232425262728293031323334
  1. import org.aspectj.testing.Tester;
  2. public class Driver {
  3. public static void main(String[] args) { test(); }
  4. public static void test() {
  5. Foo foo = new Foo();
  6. foo.m();
  7. }
  8. }
  9. aspect A {
  10. //static advice(): Foo && (void m(..) || new(..)) {
  11. //!!!no around advice allowed on constructors right now
  12. void around(): target(Foo) && call(void m(..)) {
  13. class Internal {
  14. int val() { return 1; }
  15. }
  16. int i = 1;
  17. Internal j = new Internal();
  18. proceed();
  19. Tester.checkEqual(i, 1, "i");
  20. Tester.checkEqual(j.val(), 1, "j.val()");
  21. }
  22. }
  23. class Foo {
  24. Foo() {
  25. // System.out.println("constructor Foo()");
  26. }
  27. void m() {
  28. // System.out.println("method m()");
  29. }
  30. }