< prev index next >

test/jdk/valhalla/valuetypes/MethodHandleTest.java

Print this page
rev 55117 : 8223350: [lworld] Use inline classes instead of value classes

*** 22,32 **** */ /* * @test ! * @summary test MethodHandle/VarHandle on value types * @compile -XDallowWithFieldOperator Point.java Line.java MutablePath.java MixedValues.java * @run testng/othervm -XX:+EnableValhalla MethodHandleTest */ import java.lang.invoke.*; --- 22,32 ---- */ /* * @test ! * @summary test MethodHandle/VarHandle on inline types * @compile -XDallowWithFieldOperator Point.java Line.java MutablePath.java MixedValues.java * @run testng/othervm -XX:+EnableValhalla MethodHandleTest */ import java.lang.invoke.*;
*** 69,79 **** } @Test public static void testValueFields() throws Throwable { MutablePath path = MutablePath.makePath(1, 2, 3, 4); ! // p1 and p2 are a non-final field of value type in a reference MethodHandleTest test1 = new MethodHandleTest("Point", path.p1, "x", "y"); test1.run(); MethodHandleTest test2 = new MethodHandleTest("Point", path.p2, "x", "y"); test2.run(); --- 69,79 ---- } @Test public static void testValueFields() throws Throwable { MutablePath path = MutablePath.makePath(1, 2, 3, 4); ! // p1 and p2 are a non-final field of inline type in a reference MethodHandleTest test1 = new MethodHandleTest("Point", path.p1, "x", "y"); test1.run(); MethodHandleTest test2 = new MethodHandleTest("Point", path.p2, "x", "y"); test2.run();
*** 120,134 **** } // set an array element to null Class<?> elementType = c.getComponentType(); try { ! // value array element is flattenable Object v = (Object)setter.invoke(array, 0, null); ! assertFalse(elementType.isValue(), "should fail to set a value array element to null"); } catch (NullPointerException e) { ! assertTrue(elementType.isValue(), "should only fail to set a value array element to null"); } } private final Class<?> c; private final Object o; --- 120,134 ---- } // set an array element to null Class<?> elementType = c.getComponentType(); try { ! // inline array element is flattenable Object v = (Object)setter.invoke(array, 0, null); ! assertFalse(elementType.isValue(), "should fail to set an inline class array element to null"); } catch (NullPointerException e) { ! assertTrue(elementType.isValue(), "should only fail to set an inline class array element to null"); } } private final Class<?> c; private final Object o;
*** 170,180 **** MethodHandle mh = MethodHandles.lookup().unreflectGetter(f); Object value = mh.invoke(o); } /* ! * Test setting value field to a new value. * The field must be flattenable but may or may not be flattened. */ void setValueField(String name, Object obj, Object value) throws Throwable { Field f = c.getDeclaredField(name); boolean isStatic = Modifier.isStatic(f.getModifiers()); --- 170,180 ---- MethodHandle mh = MethodHandles.lookup().unreflectGetter(f); Object value = mh.invoke(o); } /* ! * Test setting a field of an inline type to a new value. * The field must be flattenable but may or may not be flattened. */ void setValueField(String name, Object obj, Object value) throws Throwable { Field f = c.getDeclaredField(name); boolean isStatic = Modifier.isStatic(f.getModifiers());
< prev index next >