--- old/test/hotspot/jtreg/vmTestbase/nsk/jdi/ArrayType/newInstance/newinstance001.java 2018-11-07 16:35:08.000000000 -0800 +++ new/test/hotspot/jtreg/vmTestbase/nsk/jdi/ArrayType/newInstance/newinstance001.java 2018-11-07 16:35:08.000000000 -0800 @@ -148,9 +148,23 @@ log1(" TESTING BEGINS"); for (int i = 0; ; i++) { - pipe.println("newcheck"); + pipe.println("newcheck"); + + // There are potentially other non-test Java threads allocating objects and triggering + // GC's so we need to suspend the target VM to avoid the objects created in the test + // from being accidentally GC'ed. However, we need the target VM temporary resumed + // while reading its response. Below we resume the target VM (if required) and suspend + // it only after pipe.readln() returns. + + // On the first iteration the target VM is not suspended yet. + if (i > 0) { + debuggee.resume(); + } line = pipe.readln(); + // Suspending target VM to prevent other non-test Java threads from triggering GCs. + debuggee.suspend(); + if (line.equals("checkend")) { log2(" : returned string is 'checkend'"); break ; @@ -359,6 +373,7 @@ //-------------------------------------------------- test summary section //------------------------------------------------- standard end section + debuggee.resume(); pipe.println("quit"); log2("waiting for the debuggee to finish ..."); debuggee.waitFor();