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

12345678910111213141516171819202122232425262728
  1. import org.aspectj.testing.Tester;
  2. public class Driver {
  3. public static int constructorCount = 0;
  4. public static void main(String[] args) { test(); }
  5. public static void test() {
  6. SubClass sub1 = new SubClass();
  7. // only one constructor has been called
  8. Tester.checkEqual(constructorCount, 1, "constructor called");
  9. }
  10. }
  11. class SuperClass {
  12. public SuperClass() {}
  13. }
  14. class SubClass extends SuperClass {
  15. public SubClass() {}
  16. }
  17. aspect SuperAspect {
  18. after () returning(): call(SuperClass+.new(..)) {
  19. Driver.constructorCount += 1;
  20. }
  21. }