hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
changeset 38234 06263a71233c
parent 36851 03e2f4d0a421
child 38281 b28e2739b429
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java	Tue May 03 20:36:17 2016 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java	Wed May 04 17:17:10 2016 +0300
@@ -40,6 +40,7 @@
 
 public class JdkInternalMiscUnsafeAccessTestObject {
     static final int ITERS = Integer.getInteger("iters", 1);
+    static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10);
 
     static final jdk.internal.misc.Unsafe UNSAFE;
 
@@ -204,22 +205,31 @@
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSwap Object");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSwap Object");
             Object x = UNSAFE.getObject(base, offset);
             assertEquals(x, "bar", "weakCompareAndSwap Object value");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo");
-            assertEquals(r, true, "weakCompareAndSwapAcquire Object");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo");
+            }
+            assertEquals(success, true, "weakCompareAndSwapAcquire Object");
             Object x = UNSAFE.getObject(base, offset);
             assertEquals(x, "foo", "weakCompareAndSwapAcquire Object");
         }
 
         {
-            boolean r = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar");
-            assertEquals(r, true, "weakCompareAndSwapRelease Object");
+            boolean success = false;
+            for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+                success = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar");
+            }
+            assertEquals(success, true, "weakCompareAndSwapRelease Object");
             Object x = UNSAFE.getObject(base, offset);
             assertEquals(x, "bar", "weakCompareAndSwapRelease Object");
         }
@@ -236,4 +246,3 @@
 
 }
 
-