diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/OddConstructors.java | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/new/OddConstructors.java')
-rw-r--r-- | tests/new/OddConstructors.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/new/OddConstructors.java b/tests/new/OddConstructors.java new file mode 100644 index 000000000..72717d275 --- /dev/null +++ b/tests/new/OddConstructors.java @@ -0,0 +1,48 @@ +import java.lang.reflect.*; +import org.aspectj.testing.Tester; + +public class OddConstructors { + public static void main(String[] args) throws Exception { test(); } + public static void test() throws Exception { + new OddConstructors().go(); + Tester.check("advised default constructor"); + Tester.checkEqual(B.aspectOf().count, 1, "new'd once"); + } + + void go() throws Exception { + // new C(); + + // use reflection instead of new to create this class to tickle the bug + Constructor c = Class.forName("C").getConstructor(new Class[0]); + I i = (I)c.newInstance(new Object[0]); + } + static aspect B extends A issingleton() { //of eachJVM() { + pointcut i(): target(I); + } +} + + +abstract aspect A { + + abstract pointcut i(); + + pointcut j(): + i() + // 2001.08.01 (palm) + // Had to change this to I.new from new + // because of the change to the meaning + // of initialization + //&& initialization(new(..)) ; + && initialization(I.new(..)) ; + + after() returning(Object o): j() { + Tester.note("advised default constructor"); + count++; + } + + int count = 0; +} + +class C implements I { public C() {} } + +interface I {} |