From 144143c2970a1e874d74cdbd0f8c622d4282a3c3 Mon Sep 17 00:00:00 2001 From: wisberg Date: Mon, 16 Dec 2002 18:51:06 +0000 Subject: initial version --- tests/new/OddConstructors.java | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/new/OddConstructors.java (limited to 'tests/new/OddConstructors.java') 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 {} -- cgit v1.2.3