/* test implicit default constructor calls */ public class mainer { public static int initcount; public I i1; public I i2 = new I(); public I i3 = new I(10); public static I i4; public static I i5 = new I(); public static I i6 = new I(10); public static void main(String [] args) { mainer m = new mainer(); m.doit(); System.out.println("done."); } public void doit() { I i7; I i8 = new I(); I i9 = new I(10); System.out.println("i1"); i1.check(); System.out.println("i2"); i2.check(); System.out.println("i3"); i3.check(10); System.out.println("i4"); i4.check(); System.out.println("i5"); i5.check(); System.out.println("i6"); i6.check(10); System.out.println("i7"); i7.check(); System.out.println("i8"); i8.check(); System.out.println("i9"); i9.check(10); if (initcount != 9) System.out.println("init count is incorrect: " + initcount); } } immutable class I { public int w; public int x; public int y = 5; public int z = gimmeten(); public static inline int gimmeten() { return 10; } public inline I() { w = 1; mainer.initcount++; } public inline I(int x) { this(); this.x = x; } public void check(int x) { if (w != 1) System.out.println("wrong w"); if (this.x != x) System.out.println("wrong x"); if (this.y != 5) System.out.println("wrong y"); if (this.z != 10) System.out.println("wrong z"); } public void check() { check(0); } }