您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Driver.java 636B

123456789101112131415161718192021222324252627282930313233343536
  1. // inner aspects and around
  2. import org.aspectj.testing.Tester;
  3. public class Driver {
  4. public static void test() {
  5. C2 c2 = new C2();
  6. Tester.checkEqual(c2.foo(), 142, "modified c2.foo()");
  7. }
  8. public static void main(String[] args) { test(); }
  9. }
  10. class C1 {
  11. private int myInteger = 100;
  12. static aspect A {
  13. int around(C2 c2):
  14. target(c2) && call(int foo()) {
  15. int result = proceed(c2);
  16. return result + c2.getC1().myInteger;
  17. }
  18. }
  19. }
  20. class C2 {
  21. public C1 getC1() {
  22. return new C1();
  23. }
  24. int foo() {
  25. return 42;
  26. }
  27. }