< prev index next > test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java
Print this page
* 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.
*/
+ // -- This file was mechanically generated: Do not edit! -- //
+
/*
* @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessShort
*/
import java.util.List;
import static org.testng.Assert.*;
public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest {
+ static final Class<?> type = short.class;
+
static final short static_final_v = (short)0x0123;
static short static_v;
final short final_v = (short)0x0123;
VarHandle vhStaticFinalField;
VarHandle vhArray;
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
! VarHandleTestMethodHandleAccessShort.class, "final_v", short.class);
vhField = MethodHandles.lookup().findVarHandle(
! VarHandleTestMethodHandleAccessShort.class, "v", short.class);
vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
! VarHandleTestMethodHandleAccessShort.class, "static_final_v", short.class);
vhStaticField = MethodHandles.lookup().findStaticVarHandle(
! VarHandleTestMethodHandleAccessShort.class, "static_v", short.class);
vhArray = MethodHandles.arrayElementVarHandle(short[].class);
}
@DataProvider
public Object[][] accessTestCaseProvider() throws Exception {
VarHandle vhStaticFinalField;
VarHandle vhArray;
+ VarHandle vhValueTypeField;
+
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
! VarHandleTestMethodHandleAccessShort.class, "final_v", type);
vhField = MethodHandles.lookup().findVarHandle(
! VarHandleTestMethodHandleAccessShort.class, "v", type);
vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
! VarHandleTestMethodHandleAccessShort.class, "static_final_v", type);
vhStaticField = MethodHandles.lookup().findStaticVarHandle(
! VarHandleTestMethodHandleAccessShort.class, "static_v", type);
vhArray = MethodHandles.arrayElementVarHandle(short[].class);
+
+ vhValueTypeField = MethodHandles.lookup().findVarHandle(
+ Value.class, "short_v", type);
}
@DataProvider
public Object[][] accessTestCaseProvider() throws Exception {
vhArray, f, VarHandleTestMethodHandleAccessShort::testArrayUnsupported,
false));
cases.add(new MethodHandleAccessTestCase("Array index out of bounds",
vhArray, f, VarHandleTestMethodHandleAccessShort::testArrayIndexOutOfBounds,
false));
+ cases.add(new MethodHandleAccessTestCase("Value type field",
+ vhValueTypeField, f, hs -> testValueTypeField(Value.getInstance(), hs)));
+ cases.add(new MethodHandleAccessTestCase("Value type field unsupported",
+ vhValueTypeField, f, hs -> testValueTypeFieldUnsupported(Value.getInstance(), hs),
+ false));
}
// Work around issue with jtreg summary reporting which truncates
// the String result of Object.toString to 30 characters, hence
// the first dummy argument
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessShort recv, Handles hs) throws Throwable {
}
+ static void testValueTypeField(Value recv, Handles hs) throws Throwable {
+ // Plain
+ {
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x0123, "get short value");
+ }
+ }
+
+ static void testValueTypeFieldUnsupported(Value recv, Handles hs) throws Throwable {
+ // Plain
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
+ checkUOE(am, () -> {
+ hs.get(am).invokeExact(recv, (short)0x0123);
+ });
+ }
+
+
+ }
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
hs.get(TestAccessMode.SET).invokeExact((short)0x0123);
< prev index next >