test/java/lang/ref/FinalizeOverride.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8148940 Cdiff test/java/lang/ref/FinalizeOverride.java

test/java/lang/ref/FinalizeOverride.java

Print this page
rev 13766 : 8148940: java/lang/ref/FinalizeOverride.java can time out due to frequent safepointing
Summary: Reduce the freqency of triggering GCs by sleeping between GCs.
Reviewed-by: thartmann, shade

*** 27,37 **** import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicInteger; /* @test ! * @bug 8027351 * @summary Basic test of the finalize method */ public class FinalizeOverride { // finalizedCount is incremented when the finalize method is invoked --- 27,37 ---- import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicInteger; /* @test ! * @bug 8027351 8148940 * @summary Basic test of the finalize method */ public class FinalizeOverride { // finalizedCount is incremented when the finalize method is invoked
*** 61,70 **** --- 61,83 ---- // force GC and finalization o = null; while (finalizedCount.get() != (count+1)) { System.gc(); System.runFinalization(); + // Running System.gc() and System.runFinalization() in a + // tight loop can trigger frequent safepointing that slows + // down the VM and, as a result, the test. (With the + // HotSpot VM, the effect of frequent safepointing is + // especially noticeable if the test is run with the + // -Xcomp flag.) Sleeping for a second after every + // garbage collection and finalization cycle gives the VM + // time to make progress. + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + System.out.println("Main thread interrupted, continuing execution."); + } } if (privateFinalizeInvoked) { throw new RuntimeException("private finalize method invoked"); }
test/java/lang/ref/FinalizeOverride.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File