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.

ConstructorSignatures.java 838B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Does annotating 'new' with a type work as desired?
  2. import org.aspectj.testing.Tester;
  3. public class ConstructorSignatures {
  4. public static void main(String[] args) {
  5. new A1();
  6. Tester.checkEqual(A.a0, 2, "A0 advice overcalled");
  7. Tester.checkEqual(A.a1, 1, "A1 advice overcalled");
  8. Tester.checkEqual(A.b, 0, "B advice overcalled");
  9. A.a0 = A.a1 = A.b = 0;
  10. new B();
  11. Tester.checkEqual(A.a0, 0, "-A0 advice overcalled");
  12. Tester.checkEqual(A.a1, 0, "-A1 advice overcalled");
  13. Tester.checkEqual(A.b, 1, "-B advice overcalled");
  14. }
  15. }
  16. class A0 { }
  17. class A1 extends A0 { }
  18. class B {}
  19. aspect A {
  20. static int a0, a1, b;
  21. /*static*/ before(): execution(A0+.new()) { //added +
  22. a0++;
  23. }
  24. /*static*/ before(): execution(A1.new()) {
  25. a1++;
  26. }
  27. /*static*/ before(): execution(B.new()) {
  28. b++;
  29. }
  30. }