< prev index next > test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.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 VarHandleTestMethodHandleAccessBoolean
*/
import java.util.List;
import static org.testng.Assert.*;
public class VarHandleTestMethodHandleAccessBoolean extends VarHandleBaseTest {
+ static final Class<?> type = boolean.class;
+
static final boolean static_final_v = true;
static boolean static_v;
final boolean final_v = true;
VarHandle vhStaticFinalField;
VarHandle vhArray;
+ VarHandle vhValueTypeField;
+
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
- VarHandleTestMethodHandleAccessBoolean.class, "final_v", boolean.class);
+ VarHandleTestMethodHandleAccessBoolean.class, "final_v", type);
vhField = MethodHandles.lookup().findVarHandle(
- VarHandleTestMethodHandleAccessBoolean.class, "v", boolean.class);
+ VarHandleTestMethodHandleAccessBoolean.class, "v", type);
vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle(
- VarHandleTestMethodHandleAccessBoolean.class, "static_final_v", boolean.class);
+ VarHandleTestMethodHandleAccessBoolean.class, "static_final_v", type);
vhStaticField = MethodHandles.lookup().findStaticVarHandle(
- VarHandleTestMethodHandleAccessBoolean.class, "static_v", boolean.class);
+ VarHandleTestMethodHandleAccessBoolean.class, "static_v", type);
vhArray = MethodHandles.arrayElementVarHandle(boolean[].class);
+
+ vhValueTypeField = MethodHandles.lookup().findVarHandle(
+ Value.class, "boolean_v", type);
}
@DataProvider
public Object[][] accessTestCaseProvider() throws Exception {
vhArray, f, VarHandleTestMethodHandleAccessBoolean::testArrayUnsupported,
false));
cases.add(new MethodHandleAccessTestCase("Array index out of bounds",
vhArray, f, VarHandleTestMethodHandleAccessBoolean::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 testValueTypeField(Value recv, Handles hs) throws Throwable {
+ // Plain
+ {
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, true, "get boolean value");
+ }
+ }
+
+ static void testValueTypeFieldUnsupported(Value recv, Handles hs) throws Throwable {
+ // Plain
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
+ checkUOE(am, () -> {
+ hs.get(am).invokeExact(recv, true);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ checkUOE(am, () -> {
+ boolean r = (boolean) hs.get(am).invokeExact(recv, true);
+ });
+ }
+
+ }
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
hs.get(TestAccessMode.SET).invokeExact(true);
< prev index next >