From: aclement Date: Wed, 12 May 2004 13:02:27 +0000 (+0000) Subject: Test for Bugzilla Bug 61538 X-Git-Tag: V1_2_0~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=052de1776081d412871faabef068de543e21f360;p=aspectj.git Test for Bugzilla Bug 61538 nested uses of this() inside constructors not handled properly for initialization and preinitialization pointcuts --- diff --git a/tests/bugs/ConstructorMain.java b/tests/bugs/ConstructorMain.java new file mode 100644 index 000000000..3814d9a91 --- /dev/null +++ b/tests/bugs/ConstructorMain.java @@ -0,0 +1,117 @@ +public class ConstructorMain { // Bug 61538 + + public static void main(String args[]) { + + ConstructorAspects.preinitcalls = 0; + B b1 = new B(); + // preinitcalls should be 2 + // System.out.println("Preinitcalls="+ConstructorAspects.preinitcalls); + int bPreinitcalls = ConstructorAspects.preinitcalls; + + // Only difference between B and C is the order in which the + // constructors are declared in the class file + ConstructorAspects.preinitcalls = 0; + C c1 = new C(); + // preinitcalls should be 2 + // System.out.println("Preinitcalls="+ConstructorAspects.preinitcalls); + int cPreinitcalls = ConstructorAspects.preinitcalls; + + if (bPreinitcalls!=cPreinitcalls) + throw new RuntimeException("Both b("+bPreinitcalls+") and c("+cPreinitcalls+") should report the same number of preinit jps"); + } +} + +class A { + int x = 4; + A (int x) { this.x = x; } +} + +class B extends A { + int y; + static int k = 4; + static int j = 5; + static int l = 6; + + B (int x, int y) { super(x+y); this.y = x+y; } + + B (int x) { this(x+l, x+l); this.y = x+l; } + + B () { this(k+j); this.y = l; } + + +} +class C extends A { + int y; + static int k = 4; + static int j = 5; + static int l = 6; + + C () { this(k+j); this.y = l; } + + C (int x) { this(x+l, x+l); this.y = x+l; } + + C (int x, int y) { super(x+y); this.y = x+y; } + +} + + +aspect ConstructorAspects { + + public static int preinitcalls = 0; + public static int initcalls = 0; + public static int execs = 0; + + static private int aspectnesting = 0; + private final static boolean log = false; + + static void message(String s) { + if (log) { + for (int i=0; i