changeset 419:ea0195854007

interrupt.WeakReferenceTest times out with concurrent-only GCs
author shade
date Sat, 03 Nov 2018 21:24:27 +0100
parents ff7cf32e6950
children 6510f53ebe89
files tests-custom/src/main/java/org/openjdk/jcstress/tests/interrupt/WeakReferenceTest.java
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tests-custom/src/main/java/org/openjdk/jcstress/tests/interrupt/WeakReferenceTest.java	Sun Sep 02 11:10:43 2018 +0200
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/interrupt/WeakReferenceTest.java	Sat Nov 03 21:24:27 2018 +0100
@@ -57,11 +57,24 @@
         ref = new WeakReference<>(referent, refQueue);
     }
 
-
     @Actor
     public void actor1() {
         while (ref.get() != null) {
-            // burn!
+            work();
+        }
+    }
+
+    static long sink;
+
+    void work() {
+        // Need to have something to work on before GC has any chance to react.
+        // This is especially important for SATB-style GCs like G1 and Shenandoah.
+        long t = sink;
+        for (long i = 1_000_000; i > 0; i--) {
+            t += (t * 0x5DEECE66DL + 0xBL + i) & (0xFFFFFFFFFFFFL);
+        }
+        if (t == 42) {
+            sink += t;
         }
     }