8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently
authorvlivanov
Wed, 02 Mar 2016 15:42:03 +0300
changeset 36349 6cc8e6f596b2
parent 36348 f20b8728bad1
child 36350 29d8bb1668f5
child 36351 c16f26ae72c9
child 36549 d191b3de2ad3
8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently Reviewed-by: zmajo, shade
hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java
--- a/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java	Wed Mar 02 12:29:17 2016 +0300
+++ b/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java	Wed Mar 02 15:42:03 2016 +0300
@@ -182,6 +182,10 @@
         static long    testJ_U() { return U.getLongUnaligned(  STABLE_LONG_ARRAY,  ARRAY_LONG_BASE_OFFSET + 1); }
     }
 
+    static void run(Callable<?> c) throws Exception {
+        run(c, null, null);
+    }
+
     static void run(Callable<?> c, Runnable sameResultAction, Runnable changeResultAction) throws Exception {
         Object first = c.call();
 
@@ -295,13 +299,7 @@
         testMatched(   Test::testD_D, Test::changeD);
 
         // Object[], aligned accesses
-        testMismatched(Test::testL_Z, Test::changeL);
-        testMismatched(Test::testL_B, Test::changeL);
-        testMismatched(Test::testL_S, Test::changeL);
-        testMismatched(Test::testL_C, Test::changeL);
-        testMismatched(Test::testL_I, Test::changeL);
-        testMismatched(Test::testL_J, Test::changeL);
-        testMismatched(Test::testL_F, Test::changeL);
+        testMismatched(Test::testL_J, Test::changeL); // long & double are always as large as an OOP
         testMismatched(Test::testL_D, Test::changeL);
         testMatched(   Test::testL_L, Test::changeL);
 
@@ -310,5 +308,17 @@
         testMismatched(Test::testC_U, Test::changeC);
         testMismatched(Test::testI_U, Test::changeI);
         testMismatched(Test::testJ_U, Test::changeJ);
+
+        // No way to reliably check the expected behavior:
+        //   (1) OOPs change during GC;
+        //   (2) there's no way to reliably change some part of an OOP (e.g., when reading a byte from it).
+        //
+        // Just trigger the compilation hoping to catch any problems with asserts.
+        run(Test::testL_B);
+        run(Test::testL_Z);
+        run(Test::testL_S);
+        run(Test::testL_C);
+        run(Test::testL_I);
+        run(Test::testL_F);
     }
 }