--- old/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java 2018-03-22 16:48:35.000000000 -0700 +++ new/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java 2018-03-22 16:48:35.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, 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 @@ -23,7 +23,7 @@ /* * @test - * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessInt + * @run testng/othervm -Xint -Diters=2000 VarHandleTestMethodHandleAccessInt */ import org.testng.annotations.BeforeClass; @@ -57,6 +57,8 @@ VarHandle vhArray; + VarHandle vhValueTypeField; + @BeforeClass public void setup() throws Exception { vhFinalField = MethodHandles.lookup().findVarHandle( @@ -72,6 +74,9 @@ VarHandleTestMethodHandleAccessInt.class, "static_v", int.class); vhArray = MethodHandles.arrayElementVarHandle(int[].class); + + vhValueTypeField = MethodHandles.lookup().findVarHandle( + Value.class, "int_v", int.class); } @@ -100,6 +105,11 @@ cases.add(new MethodHandleAccessTestCase("Array index out of bounds", vhArray, f, VarHandleTestMethodHandleAccessInt::testArrayIndexOutOfBounds, false)); + 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)); } // Work around issue with jtreg summary reporting which truncates @@ -373,6 +383,24 @@ } + static void testValueTypeField(Value recv, Handles hs) throws Throwable { + // Plain + { + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, 0x01234567, "get int value"); + } + } + + static void testValueTypeFieldUnsupported(Value recv, Handles hs) throws Throwable { + // Plain + for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { + checkUOE(am, () -> { + hs.get(am).invokeExact(recv, 0x01234567); + }); + } + + + } static void testStaticField(Handles hs) throws Throwable { // Plain