< prev index next >
test/jdk/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template
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.
@@ -19,17 +19,30 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+#if[Value]
+/*
+ * @test
+ * @compile -XDenableValueTypes Value.java
+ * @run testng/othervm -Xverify:none -Diters=10 -Xint VarHandleTestAccess$Type$
+ */
+/* Disabled temporarily for lworld
+ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccess$Type$
+ * @run testng/othervm -Diters=20000 VarHandleTestAccess$Type$
+ * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccess$Type$
+ */
+#else[Value]
/*
* @test
* @run testng/othervm -Diters=10 -Xint VarHandleTestAccess$Type$
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccess$Type$
* @run testng/othervm -Diters=20000 VarHandleTestAccess$Type$
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccess$Type$
*/
+#end[Value]
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -58,10 +71,14 @@
VarHandle vhStaticFinalField;
VarHandle vhArray;
+#if[Value]
+ VarHandle vhValueTypeField;
+#end[Value]
+
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccess$Type$.class, "final_v", $type$.class);
@@ -73,10 +90,15 @@
vhStaticField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccess$Type$.class, "static_v", $type$.class);
vhArray = MethodHandles.arrayElementVarHandle($type$[].class);
+
+#if[Value]
+ vhValueTypeField = MethodHandles.lookup().findVarHandle(
+ Value.class, "$type$_v", $type$.class);
+#end[Value]
}
@DataProvider
public Object[][] varHandlesProvider() throws Exception {
@@ -240,10 +262,17 @@
vhArray, VarHandleTestAccess$Type$::testArrayUnsupported,
false));
cases.add(new VarHandleAccessTestCase("Array index out of bounds",
vhArray, VarHandleTestAccess$Type$::testArrayIndexOutOfBounds,
false));
+#if[Value]
+ 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));
+#end[Value]
// 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);
@@ -402,10 +431,25 @@
$type$ o = ($type$) vh.getAndBitwiseXorRelease(recv, $value1$);
});
#end[Bitwise]
}
+#if[Value]
+ static void testValueTypeField(Value recv, VarHandle vh) {
+ // Plain
+ {
+ $type$ x = ($type$) vh.get(recv);
+ assertEquals(x, $value1$, "get $type$ value");
+ }
+ }
+
+ static void testValueTypeFieldUnsupported(Value recv, VarHandle vh) {
+ checkUOE(() -> {
+ vh.set(recv, $value2$);
+ });
+ }
+#end[Value]
static void testStaticFinalField(VarHandle vh) {
// Plain
{
$type$ x = ($type$) vh.get();
< prev index next >