/* same as constructortest.ti, except everything is declared inline */ public class mainer { public static void main(String[]args) { System.out.println("Test chaining 1..4"); C x = new C(1,2,3); System.out.println("checking"); x.check(1,2,3); System.out.println("testing dynamic dispatch foo"); x.doit(); System.out.println("testing interface call"); F f = x; f.check(1,2,3); f.doit(); System.out.println("Test immutable default constructor chaining 1..2"); I i1; System.out.println("checking"); i1.check(10,20,30); System.out.println("Test immutable constructor chaining 1..3"); I i2 = new I(1,2,3); System.out.println("checking"); i2.check(1,2,3); D d = new D(); System.out.println("testing default constructor"); d.callsync(); System.out.println("ok"); E e = new E(13); System.out.println("testing this&super arg lowering"); e.check(13); System.out.println("done"); } } interface F { public void check(int a, int b, int c); public void doit(); } class A { public int x = 10; public int a = 0; public inline A(int a) { this.a = a; System.out.println("ok1"); } public inline void foo() { System.out.println("okfoo"); foo2(); } public inline void foo2() { System.out.println("wrongfoo2!!!"); } } class B extends A { public int y = 20; public int b = 0; public inline B(int a, int b) { super(a); this.b = b; System.out.println("ok2"); } public inline void bogus1() { System.out.println("wrong method!!!"); } public inline void bogus2() { System.out.println("wrong method!!!"); } } class C extends B implements F { public int z = 30; public int c = 0; public inline C(int a, int b, int c) { this(a,b,c,0); System.out.println("ok4"); } private inline C(int a, int b, int c, int junk) { super(a,b); this.c = c; System.out.println("ok3"); } public inline void foo() { System.out.println("wrong method!!!"); } public inline void doit_() { super.foo(); } public inline void foo2() { System.out.println("okfoo2"); } public inline void doit() { this.doit_(); } public inline void check(int a, int b, int c) { if (x != 10) System.out.println("wrong x"); if (y != 20) System.out.println("wrong y"); if (z != 30) System.out.println("wrong z"); if (this.a != a) System.out.println("wrong a"); if (this.b != b) System.out.println("wrong b"); if (this.c != c) System.out.println("wrong c"); } } immutable class I { public int a; public int b; public int c; // bug here in original compiler - leave off for now //public int d = 101; //public int e = 102; public inline I(double f) { System.out.println("okdI1"); a = 10; b = 20; c = 30; } public inline I() { this(1.1); System.out.println("okdI2"); } public inline I(int a, int b, int c) { this(a,b); System.out.println("okI3"); this.c = c; } public inline I(int a, int b) { this(a); System.out.println("okI2"); this.b = b; } public inline I(int a) { this.a = a; System.out.println("okI1"); } public inline void check(int a, int b, int c) { if (this.a != a) System.out.println("wrong a"); if (this.b != b) System.out.println("wrong b"); if (this.c != c) System.out.println("wrong c"); //if (this.d != 101) System.out.println("wrong d"); //if (this.e != 102) System.out.println("wrong e"); } } class D { int x = 40; public inline synchronized void callsync() { if (x != 40) System.out.println("wrong D.x"); } } class E extends A { public int r = -1; public inline E(int r) { this(r+10,0); } private inline E(int r,int junk) { super(r+10); this.r = r; } public inline void check(int r) { if (this.r != r + 10) System.out.println("wrong r"); if (this.a != r + 20) System.out.println("wrong a"); } }