// Test that GC sees pointers inside region-allocated objects class Test1 { public static void main(String[] args) throws RegionInUse { int total = 0; int iters = Integer.parseInt(args[0]); // Allocate a GC list accessible only via a region object PrivateRegion r = new PrivateRegion(); Holder robj = new (r) Holder(10, 22); // Allocate lots of memory (force a few gcs) for (int n = iters; n > 0; n--) new Holder(10, 77); // Should print 220 System.out.println("" + robj.l.sum()); } } class Holder { IList l; Holder(int n, int m) { for (int i = 0; i < n; i++) l = new IList(m, l); } } class IList { private IList cdr; private int car; IList(int pcar, IList pcdr) { cdr = pcdr; car = pcar; } int car() { return car; } IList cdr() { return cdr; } int sum() { return car + (cdr != null ? cdr.sum() : 0); } }