Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

TypeDeclInAdvice.java 635B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import org.aspectj.testing.Tester;
  2. public class TypeDeclInAdvice {
  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. void around(): this(Foo) && call(void m(..)) {
  11. class Internal {
  12. int val() { return 1; }
  13. }
  14. int i = 0;
  15. Internal j;
  16. i = 1;
  17. j = new Internal();
  18. proceed();
  19. //System.out.println("j: " + j);
  20. Tester.checkEqual(i, 1, "i");
  21. Tester.checkEqual(j.val(), 1, "j.val()");
  22. }
  23. }
  24. class Foo {
  25. Foo() {
  26. //System.out.println("constructor Foo()");
  27. }
  28. void m() {
  29. //System.out.println("method m()");
  30. }
  31. }