< prev index next >
test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2015, 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 ****
* questions.
*/
/*
* @test
! * @run testng/othervm -Diters=10 -Xint VarHandleTestAccessDouble
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessDouble
* @run testng/othervm -Diters=20000 VarHandleTestAccessDouble
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessDouble
*/
--- 21,34 ----
* questions.
*/
/*
* @test
! * @compile -XDenableValueTypes Value.java
! * @run testng/othervm -Xverify:none -Diters=10 -Xint VarHandleTestAccessDouble
! */
! /* Disabled temporarily for lworld
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessDouble
* @run testng/othervm -Diters=20000 VarHandleTestAccessDouble
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessDouble
*/
*** 58,67 ****
--- 61,72 ----
VarHandle vhStaticFinalField;
VarHandle vhArray;
+ VarHandle vhValueTypeField;
+
@BeforeClass
public void setup() throws Exception {
vhFinalField = MethodHandles.lookup().findVarHandle(
VarHandleTestAccessDouble.class, "final_v", double.class);
*** 73,82 ****
--- 78,90 ----
vhStaticField = MethodHandles.lookup().findStaticVarHandle(
VarHandleTestAccessDouble.class, "static_v", double.class);
vhArray = MethodHandles.arrayElementVarHandle(double[].class);
+
+ vhValueTypeField = MethodHandles.lookup().findVarHandle(
+ Value.class, "double_v", double.class);
}
@DataProvider
public Object[][] varHandlesProvider() throws Exception {
*** 208,217 ****
--- 216,230 ----
vhArray, VarHandleTestAccessDouble::testArrayUnsupported,
false));
cases.add(new VarHandleAccessTestCase("Array index out of bounds",
vhArray, VarHandleTestAccessDouble::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);
*** 310,319 ****
--- 323,345 ----
checkUOE(() -> {
double o = (double) vh.getAndBitwiseXorRelease(recv, 1.0d);
});
}
+ static void testValueTypeField(Value recv, VarHandle vh) {
+ // Plain
+ {
+ double x = (double) vh.get(recv);
+ assertEquals(x, 1.0d, "get double value");
+ }
+ }
+
+ static void testValueTypeFieldUnsupported(Value recv, VarHandle vh) {
+ checkUOE(() -> {
+ vh.set(recv, 2.0d);
+ });
+ }
static void testStaticFinalField(VarHandle vh) {
// Plain
{
double x = (double) vh.get();
< prev index next >