< prev index next >

test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -21,11 +21,14 @@
  * questions.
  */
 
 /*
  * @test
- * @run testng/othervm -Diters=10    -Xint                   VarHandleTestAccessInt
+ * @compile -XDenableValueTypes Value.java
+ * @run testng/othervm -Xverify:none -Diters=10    -Xint                   VarHandleTestAccessInt
+ */
+/* Disabled temporarily for lworld
  * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessInt
  * @run testng/othervm -Diters=20000                         VarHandleTestAccessInt
  * @run testng/othervm -Diters=20000 -XX:-TieredCompilation  VarHandleTestAccessInt
  */
 

@@ -58,10 +61,12 @@
 
     VarHandle vhStaticFinalField;
 
     VarHandle vhArray;
 
+    VarHandle vhValueTypeField;
+
     @BeforeClass
     public void setup() throws Exception {
         vhFinalField = MethodHandles.lookup().findVarHandle(
                 VarHandleTestAccessInt.class, "final_v", int.class);
 

@@ -73,10 +78,13 @@
 
         vhStaticField = MethodHandles.lookup().findStaticVarHandle(
             VarHandleTestAccessInt.class, "static_v", int.class);
 
         vhArray = MethodHandles.arrayElementVarHandle(int[].class);
+
+        vhValueTypeField = MethodHandles.lookup().findVarHandle(
+                    Value.class, "int_v", int.class);
     }
 
 
     @DataProvider
     public Object[][] varHandlesProvider() throws Exception {

@@ -208,10 +216,15 @@
                                               vhArray, VarHandleTestAccessInt::testArrayUnsupported,
                                               false));
         cases.add(new VarHandleAccessTestCase("Array index out of bounds",
                                               vhArray, VarHandleTestAccessInt::testArrayIndexOutOfBounds,
                                               false));
+        cases.add(new VarHandleAccessTestCase("Value type field",
+                                              vhValueTypeField, vh -> testValueTypeField(Value.VT, vh)));
+        cases.add(new VarHandleAccessTestCase("Value type field unsupported",
+                                              vhValueTypeField, vh -> testValueTypeFieldUnsupported(Value.VT, vh),
+                                              false));
 
         // Work around issue with jtreg summary reporting which truncates
         // the String result of Object.toString to 30 characters, hence
         // the first dummy argument
         return cases.stream().map(tc -> new Object[]{tc.toString(), tc}).toArray(Object[][]::new);

@@ -275,10 +288,23 @@
 
 
 
     }
 
+    static void testValueTypeField(Value recv, VarHandle vh) {
+        // Plain
+        {
+            int x = (int) vh.get(recv);
+            assertEquals(x, 0x01234567, "get int value");
+        }
+    }
+
+    static void testValueTypeFieldUnsupported(Value recv, VarHandle vh) {
+        checkUOE(() -> {
+            vh.set(recv, 0x89ABCDEF);
+        });
+    }
 
     static void testStaticFinalField(VarHandle vh) {
         // Plain
         {
             int x = (int) vh.get();
< prev index next >