< prev index next >
test/jdk/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2015, 2016, 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.
--- 1,7 ----
/*
! * 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,31 ****
--- 21,35 ----
* questions.
*/
/*
* @test
+ #if[Value]
+ * @run testng/othervm -Xint -Diters=2000 VarHandleTestMethodHandleAccess$Type$
+ #else[Value]
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccess$Type$
+ #end[Value]
*/
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
*** 55,64 ****
--- 59,72 ----
VarHandle vhStaticFinalField;
VarHandle vhArray;
+ #if[Value]
+ VarHandle vhValueTypeField;
+ #end[Value]
+
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
VarHandleTestMethodHandleAccess$Type$.class, "final_v", $type$.class);
*** 70,79 ****
--- 78,92 ----
vhStaticField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestMethodHandleAccess$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[][] accessTestCaseProvider() throws Exception {
*** 98,107 ****
--- 111,127 ----
vhArray, f, VarHandleTestMethodHandleAccess$Type$::testArrayUnsupported,
false));
cases.add(new MethodHandleAccessTestCase("Array index out of bounds",
vhArray, f, VarHandleTestMethodHandleAccess$Type$::testArrayIndexOutOfBounds,
false));
+ #if[Value]
+ cases.add(new MethodHandleAccessTestCase("Value type field",
+ vhValueTypeField, f, hs -> testValueTypeField(Value.VT, hs)));
+ cases.add(new MethodHandleAccessTestCase("Value type field unsupported",
+ vhValueTypeField, f, hs -> testValueTypeFieldUnsupported(Value.VT, hs),
+ 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
*** 410,419 ****
--- 430,492 ----
});
}
#end[Bitwise]
}
+ #if[Value]
+ static void testValueTypeField(Value recv, Handles hs) throws Throwable {
+ // Plain
+ {
+ $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, $value1$, "get $type$ value");
+ }
+ }
+
+ static void testValueTypeFieldUnsupported(Value recv, Handles hs) throws Throwable {
+ // Plain
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
+ checkUOE(am, () -> {
+ hs.get(am).invokeExact(recv, $value1$);
+ });
+ }
+ #if[!CAS]
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ checkUOE(am, () -> {
+ boolean r = (boolean) hs.get(am).invokeExact(recv, $value1$, $value2$);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ checkUOE(am, () -> {
+ $type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$, $value2$);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ checkUOE(am, () -> {
+ $type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$);
+ });
+ }
+ #end[CAS]
+
+ #if[!AtomicAdd]
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ checkUOE(am, () -> {
+ $type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$);
+ });
+ }
+ #end[AtomicAdd]
+
+ #if[!Bitwise]
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_BITWISE)) {
+ checkUOE(am, () -> {
+ $type$ r = ($type$) hs.get(am).invokeExact(recv, $value1$);
+ });
+ }
+ #end[Bitwise]
+ }
+ #end[Value]
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
hs.get(TestAccessMode.SET).invokeExact($value1$);
< prev index next >