summaryrefslogtreecommitdiffstats
path: root/tests/base/test112/Driver.java
blob: 6e8a757c968109be88253b9ba37a502d3c959a92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import org.aspectj.testing.Tester;

public class Driver {
  public static int constructorCount = 0;

  public static void main(String[] args) { test(); }
  
  public static void test() {
    SubClass sub1 = new SubClass();
    // only one constructor has been called
    Tester.checkEqual(constructorCount, 1, "constructor called");
  }
}


class SuperClass {
  public SuperClass() {}
}

class SubClass extends SuperClass {
  public SubClass() {}
}

aspect SuperAspect {
    after () returning(): call(SuperClass+.new(..)) {
        Driver.constructorCount += 1;
    }
}