# HG changeset patch # User shade # Date 1462371448 -10800 # Node ID 674cfd9b90cf0d4cf9249badb61ca9049fb48e1a # Parent d72736f07dbae9c3be571d6b28b5144a140396ce 8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures Reviewed-by: psandoz, vlivanov, simonis diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java Wed May 04 17:17:28 2016 +0300 @@ -40,6 +40,7 @@ abstract class VarHandleBaseTest { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); interface ThrowingRunnable { void run() throws Throwable; @@ -474,4 +475,4 @@ assertEquals(mt.parameterType(mt.parameterCount() - 1), vh.varType()); } } -} \ No newline at end of file +} diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java Wed May 04 17:17:28 2016 +0300 @@ -106,7 +106,6 @@ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java Wed May 04 17:17:28 2016 +0300 @@ -106,7 +106,6 @@ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java Wed May 04 17:17:28 2016 +0300 @@ -106,7 +106,6 @@ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java Wed May 04 17:17:28 2016 +0300 @@ -106,7 +106,6 @@ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java Wed May 04 17:17:28 2016 +0300 @@ -106,7 +106,6 @@ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java Wed May 04 17:17:28 2016 +0300 @@ -106,7 +106,6 @@ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -402,22 +401,31 @@ } { - boolean r = vh.weakCompareAndSet(recv, 1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(recv, 1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(recv); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = vh.weakCompareAndSetAcquire(recv, 2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(recv, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(recv); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = vh.weakCompareAndSetRelease(recv, 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(recv, 1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(recv); assertEquals(x, 2, "weakCompareAndSetRelease int"); } @@ -536,22 +544,31 @@ } { - boolean r = (boolean) vh.weakCompareAndSet(1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = (boolean) vh.weakCompareAndSetAcquire(2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = (boolean) vh.weakCompareAndSetRelease( 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(); assertEquals(x, 2, "weakCompareAndSetRelease int"); } @@ -673,22 +690,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, 1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, 1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, 2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(array, i); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, 1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(array, i); assertEquals(x, 2, "weakCompareAndSetRelease int"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java Wed May 04 17:17:28 2016 +0300 @@ -106,7 +106,6 @@ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -402,22 +401,31 @@ } { - boolean r = vh.weakCompareAndSet(recv, 1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(recv, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(recv); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = vh.weakCompareAndSetAcquire(recv, 2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(recv, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(recv); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = vh.weakCompareAndSetRelease(recv, 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(recv, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(recv); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } @@ -536,22 +544,31 @@ } { - boolean r = (boolean) vh.weakCompareAndSet(1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = (boolean) vh.weakCompareAndSetAcquire(2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = (boolean) vh.weakCompareAndSetRelease( 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } @@ -673,22 +690,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, 1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, 2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(array, i); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(array, i); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java Wed May 04 17:17:28 2016 +0300 @@ -106,7 +106,6 @@ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java Wed May 04 17:17:28 2016 +0300 @@ -106,7 +106,6 @@ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -416,22 +415,31 @@ } { - boolean r = vh.weakCompareAndSet(recv, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(recv, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(recv); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = vh.weakCompareAndSetAcquire(recv, "bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(recv, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) vh.get(recv); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = vh.weakCompareAndSetRelease(recv, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(recv, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) vh.get(recv); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } @@ -548,22 +556,31 @@ } { - boolean r = (boolean) vh.weakCompareAndSet("foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet("foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = (boolean) vh.weakCompareAndSetAcquire("bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire("bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) vh.get(); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = (boolean) vh.weakCompareAndSetRelease( "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease("foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) vh.get(); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } @@ -683,22 +700,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(array, i); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, "bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) vh.get(array, i); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) vh.get(array, i); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java Wed May 04 17:17:28 2016 +0300 @@ -93,7 +93,6 @@ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java Wed May 04 17:17:28 2016 +0300 @@ -93,7 +93,6 @@ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -678,22 +677,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet double value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire double"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease double"); } @@ -811,22 +819,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet double value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire double"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease double"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java Wed May 04 17:17:28 2016 +0300 @@ -93,7 +93,6 @@ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -678,22 +677,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet float value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire float"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease float"); } @@ -811,22 +819,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet float value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire float"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease float"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java Wed May 04 17:17:28 2016 +0300 @@ -93,7 +93,6 @@ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -692,22 +691,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet int value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease int"); } @@ -834,22 +842,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet int value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease int"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java Wed May 04 17:17:28 2016 +0300 @@ -93,7 +93,6 @@ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -692,22 +691,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet long value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire long"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease long"); } @@ -834,22 +842,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet long value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire long"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease long"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java Wed May 04 17:17:28 2016 +0300 @@ -93,7 +93,6 @@ assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java Wed May 04 17:17:28 2016 +0300 @@ -208,22 +208,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 2, "weakCompareAndSetRelease int"); } @@ -342,22 +351,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2, "weakCompareAndSetRelease int"); } @@ -479,22 +497,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2, "weakCompareAndSetRelease int"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java Wed May 04 17:17:28 2016 +0300 @@ -208,22 +208,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } @@ -342,22 +351,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } @@ -479,22 +497,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java Wed May 04 17:17:28 2016 +0300 @@ -208,22 +208,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, "bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } @@ -338,22 +347,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact("bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact("bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact("foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } @@ -471,22 +489,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, "bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template Wed May 04 17:17:28 2016 +0300 @@ -494,22 +494,31 @@ } { - boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(recv, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(recv); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = vh.weakCompareAndSetAcquire(recv, $value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(recv, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(recv); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(recv, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(recv); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } @@ -670,22 +679,31 @@ } { - boolean r = (boolean) vh.weakCompareAndSet($value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet($value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = (boolean) vh.weakCompareAndSetAcquire($value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire($value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = (boolean) vh.weakCompareAndSetRelease( $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease($value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } @@ -849,22 +867,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, $value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template Wed May 04 17:17:28 2016 +0300 @@ -848,22 +848,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$"); } @@ -994,22 +1003,31 @@ } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$"); } diff -r d72736f07dba -r 674cfd9b90cf jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template Fri Apr 29 09:40:08 2016 +0200 +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template Wed May 04 17:17:28 2016 +0300 @@ -209,22 +209,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } @@ -373,22 +382,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } @@ -540,22 +558,31 @@ } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); }