diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index 1701398489d..8baaaf09238 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -4403,6 +4403,16 @@ public void visitSelect(JCFieldAccess tree) { // Attribute the qualifier expression, and determine its symbol (if any). Type site = attribTree(tree.selected, env, new ResultInfo(skind, Type.noType)); + Assert.check(site == tree.selected.type); + if (tree.name == names._class && site.isPrimitiveClass()) { + /* JDK-8269956: Where a reflective (class) literal is needed, the unqualified Point.class is + * always the "primary" mirror - representing the primitive reference runtime type - thereby + * always matching the behavior of Object::getClass + */ + if (!tree.selected.hasTag(SELECT) || ((JCFieldAccess) tree.selected).name != names.val) { + tree.selected.setType(site = site.referenceProjection()); + } + } if (!pkind().contains(KindSelector.TYP_PCK)) site = capture(site); // Capture field access diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java index f4e57239f67..e985a303a67 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java @@ -4104,7 +4104,15 @@ public void visitSelect(JCFieldAccess tree) { tree.selected.hasTag(SELECT) && TreeInfo.name(tree.selected) == names._super && !types.isDirectSuperInterface(((JCFieldAccess)tree.selected).selected.type.tsym, currentClass); + /* JDK-8269956: Where a reflective (class) literal is needed, the unqualified Point.class is + * always the "primary" mirror - representing the primitive reference runtime type - thereby + * always matching the behavior of Object::getClass + */ + boolean needPrimaryMirror = tree.name == names._class && tree.selected.type.isPrimitiveReferenceType(); tree.selected = translate(tree.selected); + if (needPrimaryMirror && tree.selected.type.isPrimitiveClass()) { + tree.selected.setType(tree.selected.type.referenceProjection()); + } if (tree.name == names._class) { result = classOf(tree.selected); } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestBufferTearing.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestBufferTearing.java index 17500842a54..23bd907f439 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestBufferTearing.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestBufferTearing.java @@ -101,10 +101,10 @@ public class TestBufferTearing { static { try { - Class clazz = MyValue.class; + Class clazz = MyValue.class.asValueType(); MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodType mt = MethodType.methodType(MyValue.class); + MethodType mt = MethodType.methodType(MyValue.class.asValueType()); incrementAndCheck_mh = lookup.findVirtual(clazz, "incrementAndCheck", mt); } catch (NoSuchMethodException | IllegalAccessException e) { e.printStackTrace(); diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConvention.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConvention.java index 380ff6ccda6..1e2d5509e1c 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConvention.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConvention.java @@ -51,14 +51,14 @@ public class TestCallingConvention { Class clazz = TestCallingConvention.class; MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodType mt = MethodType.methodType(MyValue2.class, boolean.class); + MethodType mt = MethodType.methodType(MyValue2.class.asValueType(), boolean.class); test32_mh = lookup.findVirtual(clazz, "test32_interp", mt); mt = MethodType.methodType(Object.class, boolean.class); test33_mh = lookup.findVirtual(clazz, "test33_interp", mt); mt = MethodType.methodType(int.class); - test37_mh = lookup.findVirtual(Test37Value.class, "test", mt); + test37_mh = lookup.findVirtual(Test37Value.class.asValueType(), "test", mt); } catch (NoSuchMethodException | IllegalAccessException e) { e.printStackTrace(); throw new RuntimeException("Method handle lookup failed"); @@ -290,7 +290,7 @@ public void test12_verifier() { public long test13_interp(MyValue2 v, MyValue1[] va, boolean deopt) { if (deopt) { // uncommon trap - deoptimize("test13", MyValue2.class, MyValue1[].class, boolean.class, long.class); + deoptimize("test13", MyValue2.class.asValueType(), MyValue1[].class, boolean.class, long.class); } return v.hash() + va[0].hash() + va[1].hash(); } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestDeoptimizationWhenBuffering.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestDeoptimizationWhenBuffering.java index b256db2dd00..e4e1f788a3c 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestDeoptimizationWhenBuffering.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestDeoptimizationWhenBuffering.java @@ -112,7 +112,7 @@ public class TestDeoptimizationWhenBuffering { Class clazz = TestDeoptimizationWhenBuffering.class; MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodType mt = MethodType.methodType(MyValue1.class); + MethodType mt = MethodType.methodType(MyValue1.class.asValueType()); test9_mh = lookup.findStatic(clazz, "test9Callee", mt); test10_mh = lookup.findStatic(clazz, "test10Callee", mt); } catch (NoSuchMethodException | IllegalAccessException e) { @@ -206,7 +206,7 @@ public static void main(String[] args) throws Throwable { Asserts.assertEQ(args[0], "C1", "unsupported mode"); Method m = MyValue1.class.getMethod("testWithField", int.class); WHITE_BOX.makeMethodNotCompilable(m, COMP_LEVEL_FULL_OPTIMIZATION, false); - m = TestDeoptimizationWhenBuffering.class.getMethod("test3Callee", MyValue1.class); + m = TestDeoptimizationWhenBuffering.class.getMethod("test3Callee", MyValue1.class.asValueType()); WHITE_BOX.makeMethodNotCompilable(m, COMP_LEVEL_FULL_OPTIMIZATION, false); m = TestDeoptimizationWhenBuffering.class.getMethod("test9Callee"); WHITE_BOX.makeMethodNotCompilable(m, COMP_LEVEL_FULL_OPTIMIZATION, false); diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestIntrinsics.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestIntrinsics.java index 07fae417ff1..74b018f9920 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestIntrinsics.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestIntrinsics.java @@ -75,14 +75,14 @@ public boolean test1(Class supercls, Class subcls) { public void test1_verifier() { Asserts.assertTrue(test1(java.util.AbstractList.class, java.util.ArrayList.class), "test1_1 failed"); Asserts.assertTrue(test1(MyValue1.ref.class, MyValue1.ref.class), "test1_2 failed"); - Asserts.assertTrue(test1(MyValue1.class, MyValue1.class), "test1_3 failed"); - Asserts.assertTrue(test1(MyValue1.ref.class, MyValue1.class), "test1_4 failed"); - Asserts.assertFalse(test1(MyValue1.class, MyValue1.ref.class), "test1_5 failed"); + Asserts.assertTrue(test1(MyValue1.class.asValueType(), MyValue1.class.asValueType()), "test1_3 failed"); + Asserts.assertTrue(test1(MyValue1.ref.class, MyValue1.class.asValueType()), "test1_4 failed"); + Asserts.assertFalse(test1(MyValue1.class.asValueType(), MyValue1.ref.class), "test1_5 failed"); Asserts.assertTrue(test1(Object.class, java.util.ArrayList.class), "test1_6 failed"); Asserts.assertTrue(test1(Object.class, MyValue1.ref.class), "test1_7 failed"); - Asserts.assertTrue(test1(Object.class, MyValue1.class), "test1_8 failed"); + Asserts.assertTrue(test1(Object.class, MyValue1.class.asValueType()), "test1_8 failed"); Asserts.assertTrue(!test1(MyValue1.ref.class, Object.class), "test1_9 failed"); - Asserts.assertTrue(!test1(MyValue1.class, Object.class), "test1_10 failed"); + Asserts.assertTrue(!test1(MyValue1.class.asValueType(), Object.class), "test1_10 failed"); } // Verify that Class::isAssignableFrom checks with statically known classes are folded @@ -91,14 +91,14 @@ public void test1_verifier() { public boolean test2() { boolean check1 = java.util.AbstractList.class.isAssignableFrom(java.util.ArrayList.class); boolean check2 = MyValue1.ref.class.isAssignableFrom(MyValue1.ref.class); - boolean check3 = MyValue1.class.isAssignableFrom(MyValue1.class); - boolean check4 = MyValue1.ref.class.isAssignableFrom(MyValue1.class); - boolean check5 = !MyValue1.class.isAssignableFrom(MyValue1.ref.class); + boolean check3 = MyValue1.class.asValueType().isAssignableFrom(MyValue1.class.asValueType()); + boolean check4 = MyValue1.ref.class.isAssignableFrom(MyValue1.class.asValueType()); + boolean check5 = !MyValue1.class.asValueType().isAssignableFrom(MyValue1.ref.class); boolean check6 = Object.class.isAssignableFrom(java.util.ArrayList.class); boolean check7 = Object.class.isAssignableFrom(MyValue1.ref.class); - boolean check8 = Object.class.isAssignableFrom(MyValue1.class); + boolean check8 = Object.class.isAssignableFrom(MyValue1.class.asValueType()); boolean check9 = !MyValue1.ref.class.isAssignableFrom(Object.class); - boolean check10 = !MyValue1.class.isAssignableFrom(Object.class); + boolean check10 = !MyValue1.class.asValueType().isAssignableFrom(Object.class); return check1 && check2 && check3 && check4 && check5 && check6 && check7 && check8 && check9 && check10; } @@ -173,7 +173,7 @@ public Object[] test7(Class componentType, int len) { public void test7_verifier() { int len = Math.abs(rI) % 42; long hash = MyValue1.createDefaultDontInline().hashPrimitive(); - Object[] va = test7(MyValue1.class, len); + Object[] va = test7(MyValue1.class.asValueType(), len); for (int i = 0; i < len; ++i) { Asserts.assertEQ(((MyValue1)va[i]).hashPrimitive(), hash); } @@ -188,7 +188,7 @@ public boolean test8(Class c, MyValue1 vt) { @Run(test = "test8") public void test8_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); - boolean result = test8(MyValue1.class, vt); + boolean result = test8(MyValue1.class.asValueType(), vt); Asserts.assertTrue(result); result = test8(MyValue1.ref.class, vt); Asserts.assertTrue(result); @@ -217,7 +217,7 @@ public Object test10(Class c, MyValue1 vt) { @Run(test = "test10") public void test10_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); - Object result = test10(MyValue1.class, vt); + Object result = test10(MyValue1.class.asValueType(), vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); } @@ -238,7 +238,7 @@ public void test11_verifier() { @Test() public Object test12(MyValue1 vt) { - return MyValue1.class.cast(vt); + return MyValue1.class.asValueType().cast(vt); } @Run(test = "test12") @@ -366,11 +366,11 @@ public void test20_verifier() { private static final boolean V1_FLATTENED; static { try { - Field xField = MyValue1.class.getDeclaredField("x"); + Field xField = MyValue1.class.asValueType().getDeclaredField("x"); X_OFFSET = U.objectFieldOffset(xField); - Field yField = MyValue1.class.getDeclaredField("y"); + Field yField = MyValue1.class.asValueType().getDeclaredField("y"); Y_OFFSET = U.objectFieldOffset(yField); - Field v1Field = MyValue1.class.getDeclaredField("v1"); + Field v1Field = MyValue1.class.asValueType().getDeclaredField("v1"); V1_OFFSET = U.objectFieldOffset(v1Field); V1_FLATTENED = U.isFlattened(v1Field); } catch (Exception e) { @@ -788,7 +788,7 @@ public void test41_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); boolean result = test41(MyValue1.ref.class, vt); Asserts.assertTrue(result); - result = test41(MyValue1.class, vt); + result = test41(MyValue1.class.asValueType(), vt); Asserts.assertTrue(result); } @@ -891,10 +891,10 @@ public Object test48(Class c, MyValue1.ref vt) { @Run(test = "test48") public void test48_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); - Object result = test48(MyValue1.class, vt); + Object result = test48(MyValue1.class.asValueType(), vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); try { - test48(MyValue1.class, null); + test48(MyValue1.class.asValueType(), null); throw new RuntimeException("should have thrown"); } catch (NullPointerException npe) { } @@ -922,7 +922,7 @@ public void test50_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); MyValue1[] va = new MyValue1[42]; MyValue1.ref[] vba = new MyValue1.ref[42]; - Object result = test50(MyValue1.class, vt); + Object result = test50(MyValue1.class.asValueType(), vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); result = test50(MyValue1.ref.class, vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); @@ -933,7 +933,7 @@ public void test50_verifier() { result = test50(MyValue1.ref[].class, va); Asserts.assertEQ(result, va); try { - test50(MyValue1.class, null); + test50(MyValue1.class.asValueType(), null); throw new RuntimeException("should have thrown"); } catch (NullPointerException npe) { } @@ -1112,11 +1112,11 @@ public boolean test58(Class c1, Class c2) throws Exception { @Run(test = "test58") public void test58_verifier() throws Exception { - boolean res = test58(MyValue1.class, MyValue1.class); + boolean res = test58(MyValue1.class.asValueType(), MyValue1.class.asValueType()); Asserts.assertTrue(res); - res = test58(Object.class, MyValue1.class); + res = test58(Object.class, MyValue1.class.asValueType()); Asserts.assertFalse(res); - res = test58(MyValue1.class, Object.class); + res = test58(MyValue1.class.asValueType(), Object.class); Asserts.assertFalse(res); } @@ -1133,7 +1133,7 @@ public void test59(Class c) throws Exception { public void test59_verifier() throws Exception { test59(Integer.class); try { - test59(MyValue1.class); + test59(MyValue1.class.asValueType()); throw new RuntimeException("test59 failed: synchronization on inline type should not succeed"); } catch (IllegalMonitorStateException e) { @@ -1150,10 +1150,10 @@ public boolean test60(Class c1, Class c2, boolean b1, boolean b2) throws E @Run(test = "test60") public void test60_verifier() throws Exception { - Asserts.assertTrue(test60(MyValue1.class, MyValue1.class, false, false)); - Asserts.assertFalse(test60(MyValue1.class, MyValue2.class, false, false)); - Asserts.assertFalse(test60(MyValue1.class, MyValue1.class, false, true)); - Asserts.assertFalse(test60(MyValue1.class, MyValue1.class, true, false)); - Asserts.assertFalse(test60(MyValue1.class, MyValue1.class, true, true)); + Asserts.assertTrue(test60(MyValue1.class.asValueType(), MyValue1.class.asValueType(), false, false)); + Asserts.assertFalse(test60(MyValue1.class.asValueType(), MyValue2.class, false, false)); + Asserts.assertFalse(test60(MyValue1.class.asValueType(), MyValue1.class.asValueType(), false, true)); + Asserts.assertFalse(test60(MyValue1.class.asValueType(), MyValue1.class.asValueType(), true, false)); + Asserts.assertFalse(test60(MyValue1.class.asValueType(), MyValue1.class.asValueType(), true, true)); } } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMethodHandles.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMethodHandles.java index 79998d7adb0..462568372d9 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMethodHandles.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMethodHandles.java @@ -52,28 +52,28 @@ public class TestMethodHandles { Class clazz = TestMethodHandles.class; MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodType mt = MethodType.methodType(MyValue3.class); + MethodType mt = MethodType.methodType(MyValue3.class.asValueType()); test1_mh = lookup.findVirtual(clazz, "test1_target", mt); test2_mh = lookup.findVirtual(clazz, "test2_target", mt); test3_mh = lookup.findVirtual(clazz, "test3_target", mt); - MethodType test4_mt1 = MethodType.methodType(int.class, MyValue1.class); - MethodType test4_mt2 = MethodType.methodType(MyValue1.class); + MethodType test4_mt1 = MethodType.methodType(int.class, MyValue1.class.asValueType()); + MethodType test4_mt2 = MethodType.methodType(MyValue1.class.asValueType()); MethodHandle test4_mh1 = lookup.findStatic(clazz, "test4_helper1", test4_mt1); MethodHandle test4_mh2 = lookup.findStatic(clazz, "test4_helper2", test4_mt2); test4_mh = MethodHandles.filterReturnValue(test4_mh2, test4_mh1); - MethodType test5_mt = MethodType.methodType(int.class, MyValue1.class); + MethodType test5_mt = MethodType.methodType(int.class, MyValue1.class.asValueType()); test5_mh = lookup.findVirtual(clazz, "test5_target", test5_mt); - MethodType test6_mt = MethodType.methodType(MyValue3.class); + MethodType test6_mt = MethodType.methodType(MyValue3.class.asValueType()); MethodHandle test6_mh1 = lookup.findVirtual(clazz, "test6_target1", test6_mt); MethodHandle test6_mh2 = lookup.findVirtual(clazz, "test6_target2", test6_mt); MethodType boolean_mt = MethodType.methodType(boolean.class); MethodHandle test6_mh_test = lookup.findVirtual(clazz, "test6_test", boolean_mt); test6_mh = MethodHandles.guardWithTest(test6_mh_test, test6_mh1, test6_mh2); - MethodType myvalue2_mt = MethodType.methodType(MyValue2.class); + MethodType myvalue2_mt = MethodType.methodType(MyValue2.class.asValueType()); test7_mh1 = lookup.findStatic(clazz, "test7_target1", myvalue2_mt); MethodHandle test7_mh2 = lookup.findStatic(clazz, "test7_target2", myvalue2_mt); MethodHandle test7_mh_test = lookup.findStatic(clazz, "test7_test", boolean_mt); @@ -88,7 +88,7 @@ public class TestMethodHandles { MethodHandles.dropArguments(test8_mh1, 0, MethodHandle.class), MethodHandles.invoker(myvalue2_mt)); - MethodType test9_mt = MethodType.methodType(MyValue3.class); + MethodType test9_mt = MethodType.methodType(MyValue3.class.asValueType()); MethodHandle test9_mh1 = lookup.findVirtual(clazz, "test9_target1", test9_mt); MethodHandle test9_mh2 = lookup.findVirtual(clazz, "test9_target2", test9_mt); MethodHandle test9_mh3 = lookup.findVirtual(clazz, "test9_target3", test9_mt); @@ -99,12 +99,12 @@ public class TestMethodHandles { test9_mh1, MethodHandles.guardWithTest(test9_mh_test2, test9_mh2, test9_mh3)); - MethodType test10_mt = MethodType.methodType(MyValue2.class); + MethodType test10_mt = MethodType.methodType(MyValue2.class.asValueType()); MethodHandle test10_mh1 = lookup.findStatic(clazz, "test10_target1", test10_mt); test10_mh2 = lookup.findStatic(clazz, "test10_target2", test10_mt); test10_mh3 = lookup.findStatic(clazz, "test10_target3", test10_mt); MethodType test10_mt2 = MethodType.methodType(boolean.class); - MethodType test10_mt3 = MethodType.methodType(MyValue2.class); + MethodType test10_mt3 = MethodType.methodType(MyValue2.class.asValueType()); MethodHandle test10_mh_test1 = lookup.findStatic(clazz, "test10_test1", test10_mt2); MethodHandle test10_mh_test2 = lookup.findStatic(clazz, "test10_test2", test10_mt2); test10_mh = MethodHandles.guardWithTest(test10_mh_test1, diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNewAcmp.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNewAcmp.java index 2575dc65511..6e6484306b1 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNewAcmp.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNewAcmp.java @@ -1735,7 +1735,7 @@ public void runTest(Method m, Object[] args, int warmup, int nullMode, boolean[] if (args[i] != null && !parameterTypes[0].isInstance(args[i])) { continue; } - if (args[i] == null && parameterTypes[0] == MyValue1.class) { + if (args[i] == null && parameterTypes[0] == MyValue1.class.asValueType()) { continue; } if (parameterCount == 1) { @@ -1757,7 +1757,7 @@ public void runTest(Method m, Object[] args, int warmup, int nullMode, boolean[] if (args[j] != null && !parameterTypes[1].isInstance(args[j])) { continue; } - if (args[j] == null && parameterTypes[1] == MyValue1.class) { + if (args[j] == null && parameterTypes[1] == MyValue1.class.asValueType()) { continue; } System.out.print("Testing " + m.getName() + "(" + args[i] + ", " + args[j] + ")"); diff --git a/test/hotspot/jtreg/runtime/valhalla/inlinetypes/InlineOops.java b/test/hotspot/jtreg/runtime/valhalla/inlinetypes/InlineOops.java index 9ad3ce28bf5..dc515c44428 100644 --- a/test/hotspot/jtreg/runtime/valhalla/inlinetypes/InlineOops.java +++ b/test/hotspot/jtreg/runtime/valhalla/inlinetypes/InlineOops.java @@ -394,7 +394,7 @@ public static void testFrameOopsVBytecodes() { */ public static void testOverGc() { try { - Class vtClass = Person.class; + Class vtClass = Person.class.asValueType(); System.out.println("vtClass="+vtClass); @@ -672,7 +672,7 @@ public static void testFrameOopsDefault(Object[][] oopMaps) { LOOKUP, "exerciseVBytecodeExprStackWithDefault", mt, CODE->{ CODE - .defaultvalue(FooValue.class) + .defaultvalue(FooValue.class.asValueType()) .aload(oopMapsSlot) .iconst_0() // Test-D0 Slots=R Stack=Q(RRR)RV .invokestatic(InlineOops.class, GET_OOP_MAP_NAME, GET_OOP_MAP_DESC, false) @@ -682,7 +682,7 @@ public static void testFrameOopsDefault(Object[][] oopMaps) { .iconst_1() // Test-D1 Slots=R Stack=RV .invokestatic(InlineOops.class, GET_OOP_MAP_NAME, GET_OOP_MAP_DESC, false) .aastore() - .defaultvalue(FooValue.class) + .defaultvalue(FooValue.class.asValueType()) .astore(vtSlot) .aload(oopMapsSlot) .iconst_2() // Test-D2 Slots=RQ(RRR) Stack=RV diff --git a/test/hotspot/jtreg/runtime/valhalla/inlinetypes/InlineTypeArray.java b/test/hotspot/jtreg/runtime/valhalla/inlinetypes/InlineTypeArray.java index 9b7c839179a..a7887c20e03 100644 --- a/test/hotspot/jtreg/runtime/valhalla/inlinetypes/InlineTypeArray.java +++ b/test/hotspot/jtreg/runtime/valhalla/inlinetypes/InlineTypeArray.java @@ -81,7 +81,7 @@ void testClassForName() { arrayCls = Class.forName(qarrayClsName); assertTrue(arrayCls.isArray(), "Expected an array class"); - assertTrue(arrayCls.getComponentType() == Point.class, + assertTrue(arrayCls.getComponentType() == Point.class.asValueType(), arrayCls + " Expected component type of Point.class got: " + arrayCls.getComponentType()); @@ -288,7 +288,7 @@ void testSanityCheckcasts() { assertTrue(myInts instanceof Comparable[]); assertTrue(myInts instanceof MyInt[]); - Class cls = MyInt.class; + Class cls = MyInt.class.asValueType(); assertTrue(cls.isValueType()); Object arrObj = Array.newInstance(cls, 1); assertTrue(arrObj instanceof Object[], "Not Object array"); diff --git a/test/hotspot/jtreg/runtime/valhalla/inlinetypes/VarArgsArray.java b/test/hotspot/jtreg/runtime/valhalla/inlinetypes/VarArgsArray.java index a7238248702..32320c8b562 100644 --- a/test/hotspot/jtreg/runtime/valhalla/inlinetypes/VarArgsArray.java +++ b/test/hotspot/jtreg/runtime/valhalla/inlinetypes/VarArgsArray.java @@ -57,9 +57,9 @@ public void testJvmInvokeMethod() throws Throwable { MyInt[] array1 = new MyInt[] { new MyInt(TOKEN_VALUE) }; MyInt[] array2 = new MyInt[] { new MyInt(TOKEN_VALUE), new MyInt(TOKEN_VALUE) }; - Method methodARef = getClass().getDeclaredMethod("methodA", MyInt.class); - Method methodBRef = getClass().getDeclaredMethod("methodB", MyInt.class, MyInt.class); - Method methodCRef = getClass().getDeclaredMethod("methodC", MyInt.class, String.class); + Method methodARef = getClass().getDeclaredMethod("methodA", MyInt.class.asValueType()); + Method methodBRef = getClass().getDeclaredMethod("methodB", MyInt.class.asValueType(), MyInt.class.asValueType()); + Method methodCRef = getClass().getDeclaredMethod("methodC", MyInt.class.asValueType(), String.class); // Positive tests... methodARef.invoke(this, (Object[])array1); @@ -97,7 +97,7 @@ public void testJvmInvokeMethod() throws Throwable { public void testJvmNewInstanceFromConstructor() throws Throwable { // Inner classes use outer in param list, so these won't exercise inline type array Class tc = NewInstanceFromConstructor.class; - Class pt = IntValue.class; + Class pt = IntValue.class.asValueType(); Constructor consARef = tc.getConstructor(pt); Constructor consBRef = tc.getConstructor(pt, pt); Constructor consCRef = tc.getConstructor(pt, String.class); diff --git a/test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessPoint.java b/test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessPoint.java index e8955791375..9c8cb40fd3e 100644 --- a/test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessPoint.java +++ b/test/jdk/java/lang/invoke/VarHandles/VarHandleTestAccessPoint.java @@ -80,19 +80,19 @@ VarHandle[] allocate(boolean same) { VarHandle vh; try { vh = MethodHandles.lookup().findVarHandle( - VarHandleTestAccessPoint.class, "final_v" + postfix, Point.class); + VarHandleTestAccessPoint.class, "final_v" + postfix, Point.class.asValueType()); vhs.add(vh); vh = MethodHandles.lookup().findVarHandle( - VarHandleTestAccessPoint.class, "v" + postfix, Point.class); + VarHandleTestAccessPoint.class, "v" + postfix, Point.class.asValueType()); vhs.add(vh); vh = MethodHandles.lookup().findStaticVarHandle( - VarHandleTestAccessPoint.class, "static_final_v" + postfix, Point.class); + VarHandleTestAccessPoint.class, "static_final_v" + postfix, Point.class.asValueType()); vhs.add(vh); vh = MethodHandles.lookup().findStaticVarHandle( - VarHandleTestAccessPoint.class, "static_v" + postfix, Point.class); + VarHandleTestAccessPoint.class, "static_v" + postfix, Point.class.asValueType()); vhs.add(vh); if (same) { @@ -111,22 +111,22 @@ VarHandle[] allocate(boolean same) { @BeforeClass public void setup() throws Exception { vhFinalField = MethodHandles.lookup().findVarHandle( - VarHandleTestAccessPoint.class, "final_v", Point.class); + VarHandleTestAccessPoint.class, "final_v", Point.class.asValueType()); vhField = MethodHandles.lookup().findVarHandle( - VarHandleTestAccessPoint.class, "v", Point.class); + VarHandleTestAccessPoint.class, "v", Point.class.asValueType()); vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle( - VarHandleTestAccessPoint.class, "static_final_v", Point.class); + VarHandleTestAccessPoint.class, "static_final_v", Point.class.asValueType()); vhStaticField = MethodHandles.lookup().findStaticVarHandle( - VarHandleTestAccessPoint.class, "static_v", Point.class); + VarHandleTestAccessPoint.class, "static_v", Point.class.asValueType()); vhArray = MethodHandles.arrayElementVarHandle(Point[].class); vhArrayObject = MethodHandles.arrayElementVarHandle(Object[].class); vhValueTypeField = MethodHandles.lookup().findVarHandle( - Value.class, "point_v", Point.class); + Value.class, "point_v", Point.class.asValueType()); } @@ -211,7 +211,7 @@ public Object[][] typesProvider() throws Exception { @Test(dataProvider = "typesProvider") public void testTypes(VarHandle vh, List> pts) { - assertEquals(vh.varType(), Point.class); + assertEquals(vh.varType(), Point.class.asValueType()); assertEquals(vh.coordinateTypes(), pts); @@ -223,12 +223,12 @@ public void testTypes(VarHandle vh, List> pts) { public void testLookupInstanceToStatic() { checkIAE("Lookup of static final field to instance final field", () -> { MethodHandles.lookup().findStaticVarHandle( - VarHandleTestAccessPoint.class, "final_v", Point.class); + VarHandleTestAccessPoint.class, "final_v", Point.class.asValueType()); }); checkIAE("Lookup of static field to instance field", () -> { MethodHandles.lookup().findStaticVarHandle( - VarHandleTestAccessPoint.class, "v", Point.class); + VarHandleTestAccessPoint.class, "v", Point.class.asValueType()); }); } @@ -236,12 +236,12 @@ public void testLookupInstanceToStatic() { public void testLookupStaticToInstance() { checkIAE("Lookup of instance final field to static final field", () -> { MethodHandles.lookup().findVarHandle( - VarHandleTestAccessPoint.class, "static_final_v", Point.class); + VarHandleTestAccessPoint.class, "static_final_v", Point.class.asValueType()); }); checkIAE("Lookup of instance field to static field", () -> { vhStaticField = MethodHandles.lookup().findVarHandle( - VarHandleTestAccessPoint.class, "static_v", Point.class); + VarHandleTestAccessPoint.class, "static_v", Point.class.asValueType()); }); } diff --git a/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessPoint.java b/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessPoint.java index f8dc7c8a1a3..0be9ec2b8fa 100644 --- a/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessPoint.java +++ b/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessPoint.java @@ -64,21 +64,21 @@ public class VarHandleTestMethodHandleAccessPoint extends VarHandleBaseTest { @BeforeClass public void setup() throws Exception { vhFinalField = MethodHandles.lookup().findVarHandle( - VarHandleTestMethodHandleAccessPoint.class, "final_v", Point.class); + VarHandleTestMethodHandleAccessPoint.class, "final_v", Point.class.asValueType()); vhField = MethodHandles.lookup().findVarHandle( - VarHandleTestMethodHandleAccessPoint.class, "v", Point.class); + VarHandleTestMethodHandleAccessPoint.class, "v", Point.class.asValueType()); vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle( - VarHandleTestMethodHandleAccessPoint.class, "static_final_v", Point.class); + VarHandleTestMethodHandleAccessPoint.class, "static_final_v", Point.class.asValueType()); vhStaticField = MethodHandles.lookup().findStaticVarHandle( - VarHandleTestMethodHandleAccessPoint.class, "static_v", Point.class); + VarHandleTestMethodHandleAccessPoint.class, "static_v", Point.class.asValueType()); vhArray = MethodHandles.arrayElementVarHandle(Point[].class); vhValueTypeField = MethodHandles.lookup().findVarHandle( - Value.class, "point_v", Point.class); + Value.class, "point_v", Point.class.asValueType()); } diff --git a/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodTypePoint.java b/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodTypePoint.java index 06b168cbae1..f9c89ee13b7 100644 --- a/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodTypePoint.java +++ b/test/jdk/java/lang/invoke/VarHandles/VarHandleTestMethodTypePoint.java @@ -66,16 +66,16 @@ public class VarHandleTestMethodTypePoint extends VarHandleBaseTest { @BeforeClass public void setup() throws Exception { vhFinalField = MethodHandles.lookup().findVarHandle( - VarHandleTestMethodTypePoint.class, "final_v", Point.class); + VarHandleTestMethodTypePoint.class, "final_v", Point.class.asValueType()); vhField = MethodHandles.lookup().findVarHandle( - VarHandleTestMethodTypePoint.class, "v", Point.class); + VarHandleTestMethodTypePoint.class, "v", Point.class.asValueType()); vhStaticFinalField = MethodHandles.lookup().findStaticVarHandle( - VarHandleTestMethodTypePoint.class, "static_final_v", Point.class); + VarHandleTestMethodTypePoint.class, "static_final_v", Point.class.asValueType()); vhStaticField = MethodHandles.lookup().findStaticVarHandle( - VarHandleTestMethodTypePoint.class, "static_v", Point.class); + VarHandleTestMethodTypePoint.class, "static_v", Point.class.asValueType()); vhArray = MethodHandles.arrayElementVarHandle(Point[].class); } @@ -649,15 +649,15 @@ static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypePoint recv, for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - Point x = (Point) hs.get(am, methodType(Point.class, VarHandleTestMethodTypePoint.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), VarHandleTestMethodTypePoint.class)). invokeExact((VarHandleTestMethodTypePoint) null); }); hs.checkWMTEOrCCE(() -> { // receiver reference class - Point x = (Point) hs.get(am, methodType(Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Class.class)). invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class - Point x = (Point) hs.get(am, methodType(Point.class, int.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), int.class)). invokeExact(0); }); // Incorrect return type @@ -671,11 +671,11 @@ static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypePoint recv, }); // Incorrect arity checkWMTE(() -> { // 0 - Point x = (Point) hs.get(am, methodType(Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType())). invokeExact(); }); checkWMTE(() -> { // > - Point x = (Point) hs.get(am, methodType(Point.class, VarHandleTestMethodTypePoint.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), VarHandleTestMethodTypePoint.class, Class.class)). invokeExact(recv, Void.class); }); } @@ -683,11 +683,11 @@ static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypePoint recv, for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, VarHandleTestMethodTypePoint.class, Point.class)). + hs.get(am, methodType(void.class, VarHandleTestMethodTypePoint.class, Point.class.asValueType())). invokeExact((VarHandleTestMethodTypePoint) null, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // receiver reference class - hs.get(am, methodType(void.class, Class.class, Point.class)). + hs.get(am, methodType(void.class, Class.class, Point.class.asValueType())). invokeExact(Void.class, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // value reference class @@ -695,7 +695,7 @@ static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypePoint recv, invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class - hs.get(am, methodType(void.class, int.class, Point.class)). + hs.get(am, methodType(void.class, int.class, Point.class.asValueType())). invokeExact(0, Point.getInstance(1,1)); }); // Incorrect arity @@ -704,7 +704,7 @@ static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypePoint recv, invokeExact(); }); checkWMTE(() -> { // > - hs.get(am, methodType(void.class, VarHandleTestMethodTypePoint.class, Point.class, Class.class)). + hs.get(am, methodType(void.class, VarHandleTestMethodTypePoint.class, Point.class.asValueType(), Class.class)). invokeExact(recv, Point.getInstance(1,1), Void.class); }); } @@ -712,23 +712,23 @@ static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypePoint recv, for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Point.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact((VarHandleTestMethodTypePoint) null, Point.getInstance(1,1), Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // receiver reference class - boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, Point.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(Void.class, Point.getInstance(1,1), Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // expected reference class - boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Class.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Class.class, Point.class.asValueType())). invokeExact(recv, Void.class, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // actual reference class - boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Point.class, Class.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Point.class.asValueType(), Class.class)). invokeExact(recv, Point.getInstance(1,1), Void.class); }); checkWMTE(() -> { // receiver primitive class - boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , Point.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , Point.class.asValueType(), Point.class.asValueType())). invokeExact(0, Point.getInstance(1,1), Point.getInstance(1,1)); }); // Incorrect arity @@ -737,85 +737,85 @@ static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypePoint recv, invokeExact(); }); checkWMTE(() -> { // > - boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Point.class, Point.class, Class.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Point.class.asValueType(), Point.class.asValueType(), Class.class)). invokeExact(recv, Point.getInstance(1,1), Point.getInstance(1,1), Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { checkNPE(() -> { // null receiver - Point x = (Point) hs.get(am, methodType(Point.class, VarHandleTestMethodTypePoint.class, Point.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), VarHandleTestMethodTypePoint.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact((VarHandleTestMethodTypePoint) null, Point.getInstance(1,1), Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // receiver reference class - Point x = (Point) hs.get(am, methodType(Point.class, Class.class, Point.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Class.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(Void.class, Point.getInstance(1,1), Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // expected reference class - Point x = (Point) hs.get(am, methodType(Point.class, VarHandleTestMethodTypePoint.class, Class.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), VarHandleTestMethodTypePoint.class, Class.class, Point.class.asValueType())). invokeExact(recv, Void.class, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // actual reference class - Point x = (Point) hs.get(am, methodType(Point.class, VarHandleTestMethodTypePoint.class, Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), VarHandleTestMethodTypePoint.class, Point.class.asValueType(), Class.class)). invokeExact(recv, Point.getInstance(1,1), Void.class); }); checkWMTE(() -> { // reciever primitive class - Point x = (Point) hs.get(am, methodType(Point.class, int.class , Point.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), int.class , Point.class.asValueType(), Point.class.asValueType())). invokeExact(0, Point.getInstance(1,1), Point.getInstance(1,1)); }); // Incorrect return type hs.checkWMTEOrCCE(() -> { // reference class - Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypePoint.class , Point.class, Point.class)). + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypePoint.class , Point.class.asValueType(), Point.class.asValueType())). invokeExact(recv, Point.getInstance(1,1), Point.getInstance(1,1)); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class , Point.class, Point.class)). + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class , Point.class.asValueType(), Point.class.asValueType())). invokeExact(recv, Point.getInstance(1,1), Point.getInstance(1,1)); }); // Incorrect arity checkWMTE(() -> { // 0 - Point x = (Point) hs.get(am, methodType(Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType())). invokeExact(); }); checkWMTE(() -> { // > - Point x = (Point) hs.get(am, methodType(Point.class, VarHandleTestMethodTypePoint.class, Point.class, Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), VarHandleTestMethodTypePoint.class, Point.class.asValueType(), Point.class.asValueType(), Class.class)). invokeExact(recv, Point.getInstance(1,1), Point.getInstance(1,1), Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { checkNPE(() -> { // null receiver - Point x = (Point) hs.get(am, methodType(Point.class, VarHandleTestMethodTypePoint.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), VarHandleTestMethodTypePoint.class, Point.class.asValueType())). invokeExact((VarHandleTestMethodTypePoint) null, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // receiver reference class - Point x = (Point) hs.get(am, methodType(Point.class, Class.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Class.class, Point.class.asValueType())). invokeExact(Void.class, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // value reference class - Point x = (Point) hs.get(am, methodType(Point.class, VarHandleTestMethodTypePoint.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), VarHandleTestMethodTypePoint.class, Class.class)). invokeExact(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class - Point x = (Point) hs.get(am, methodType(Point.class, int.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), int.class, Point.class.asValueType())). invokeExact(0, Point.getInstance(1,1)); }); // Incorrect return type hs.checkWMTEOrCCE(() -> { // reference class - Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypePoint.class, Point.class)). + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypePoint.class, Point.class.asValueType())). invokeExact(recv, Point.getInstance(1,1)); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Point.class)). + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypePoint.class, Point.class.asValueType())). invokeExact(recv, Point.getInstance(1,1)); }); // Incorrect arity checkWMTE(() -> { // 0 - Point x = (Point) hs.get(am, methodType(Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType())). invokeExact(); }); checkWMTE(() -> { // > - Point x = (Point) hs.get(am, methodType(Point.class, VarHandleTestMethodTypePoint.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), VarHandleTestMethodTypePoint.class, Point.class.asValueType())). invokeExact(recv, Point.getInstance(1,1), Void.class); }); } @@ -1187,18 +1187,18 @@ static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { invokeExact(); }); checkWMTE(() -> { // > - hs.get(am, methodType(void.class, Point.class, Class.class)). + hs.get(am, methodType(void.class, Point.class.asValueType(), Class.class)). invokeExact(Point.getInstance(1,1), Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types hs.checkWMTEOrCCE(() -> { // expected reference class - boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, Point.class.asValueType())). invokeExact(Void.class, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // actual reference class - boolean r = (boolean) hs.get(am, methodType(boolean.class, Point.class, Class.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Point.class.asValueType(), Class.class)). invokeExact(Point.getInstance(1,1), Void.class); }); // Incorrect arity @@ -1207,7 +1207,7 @@ static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { invokeExact(); }); checkWMTE(() -> { // > - boolean r = (boolean) hs.get(am, methodType(boolean.class, Point.class, Point.class, Class.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Point.class.asValueType(), Point.class.asValueType(), Class.class)). invokeExact(Point.getInstance(1,1), Point.getInstance(1,1), Void.class); }); } @@ -1215,29 +1215,29 @@ static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { // Incorrect argument types hs.checkWMTEOrCCE(() -> { // expected reference class - Point x = (Point) hs.get(am, methodType(Point.class, Class.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Class.class, Point.class.asValueType())). invokeExact(Void.class, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // actual reference class - Point x = (Point) hs.get(am, methodType(Point.class, Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point.class.asValueType(), Class.class)). invokeExact(Point.getInstance(1,1), Void.class); }); // Incorrect return type hs.checkWMTEOrCCE(() -> { // reference class - Void r = (Void) hs.get(am, methodType(Void.class, Point.class, Point.class)). + Void r = (Void) hs.get(am, methodType(Void.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(Point.getInstance(1,1), Point.getInstance(1,1)); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) hs.get(am, methodType(boolean.class, Point.class, Point.class)). + boolean x = (boolean) hs.get(am, methodType(boolean.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(Point.getInstance(1,1), Point.getInstance(1,1)); }); // Incorrect arity checkWMTE(() -> { // 0 - Point x = (Point) hs.get(am, methodType(Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType())). invokeExact(); }); checkWMTE(() -> { // > - Point x = (Point) hs.get(am, methodType(Point.class, Point.class, Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point.class.asValueType(), Point.class.asValueType(), Class.class)). invokeExact(Point.getInstance(1,1), Point.getInstance(1,1), Void.class); }); } @@ -1245,25 +1245,25 @@ static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { // Incorrect argument types hs.checkWMTEOrCCE(() -> { // value reference class - Point x = (Point) hs.get(am, methodType(Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Class.class)). invokeExact(Void.class); }); // Incorrect return type hs.checkWMTEOrCCE(() -> { // reference class - Void r = (Void) hs.get(am, methodType(Void.class, Point.class)). + Void r = (Void) hs.get(am, methodType(Void.class, Point.class.asValueType())). invokeExact(Point.getInstance(1,1)); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) hs.get(am, methodType(boolean.class, Point.class)). + boolean x = (boolean) hs.get(am, methodType(boolean.class, Point.class.asValueType())). invokeExact(Point.getInstance(1,1)); }); // Incorrect arity checkWMTE(() -> { // 0 - Point x = (Point) hs.get(am, methodType(Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType())). invokeExact(); }); checkWMTE(() -> { // > - Point x = (Point) hs.get(am, methodType(Point.class, Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point.class.asValueType(), Class.class)). invokeExact(Point.getInstance(1,1), Void.class); }); } @@ -1861,19 +1861,19 @@ static void testArrayWrongMethodType(Handles hs) throws Throwable { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, int.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, int.class)). invokeExact((Point[]) null, 0); }); hs.checkWMTEOrCCE(() -> { // array reference class - Point x = (Point) hs.get(am, methodType(Point.class, Class.class, int.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Class.class, int.class)). invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class - Point x = (Point) hs.get(am, methodType(Point.class, int.class, int.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), int.class, int.class)). invokeExact(0, 0); }); checkWMTE(() -> { // index reference class - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, Class.class)). invokeExact(array, Void.class); }); // Incorrect return type @@ -1887,11 +1887,11 @@ static void testArrayWrongMethodType(Handles hs) throws Throwable { }); // Incorrect arity checkWMTE(() -> { // 0 - Point x = (Point) hs.get(am, methodType(Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType())). invokeExact(); }); checkWMTE(() -> { // > - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, int.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, int.class, Class.class)). invokeExact(array, 0, Void.class); }); } @@ -1899,11 +1899,11 @@ static void testArrayWrongMethodType(Handles hs) throws Throwable { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Point[].class, int.class, Point.class)). + hs.get(am, methodType(void.class, Point[].class, int.class, Point.class.asValueType())). invokeExact((Point[]) null, 0, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // array reference class - hs.get(am, methodType(void.class, Class.class, int.class, Point.class)). + hs.get(am, methodType(void.class, Class.class, int.class, Point.class.asValueType())). invokeExact(Void.class, 0, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // value reference class @@ -1911,11 +1911,11 @@ static void testArrayWrongMethodType(Handles hs) throws Throwable { invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class - hs.get(am, methodType(void.class, int.class, int.class, Point.class)). + hs.get(am, methodType(void.class, int.class, int.class, Point.class.asValueType())). invokeExact(0, 0, Point.getInstance(1,1)); }); checkWMTE(() -> { // index reference class - hs.get(am, methodType(void.class, Point[].class, Class.class, Point.class)). + hs.get(am, methodType(void.class, Point[].class, Class.class, Point.class.asValueType())). invokeExact(array, Void.class, Point.getInstance(1,1)); }); // Incorrect arity @@ -1931,27 +1931,27 @@ static void testArrayWrongMethodType(Handles hs) throws Throwable { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact((Point[]) null, 0, Point.getInstance(1,1), Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // receiver reference class - boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, Point.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(Void.class, 0, Point.getInstance(1,1), Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // expected reference class - boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Class.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Class.class, Point.class.asValueType())). invokeExact(array, 0, Void.class, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // actual reference class - boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class, Class.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class.asValueType(), Class.class)). invokeExact(array, 0, Point.getInstance(1,1), Void.class); }); checkWMTE(() -> { // receiver primitive class - boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, Point.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(0, 0, Point.getInstance(1,1), Point.getInstance(1,1)); }); checkWMTE(() -> { // index reference class - boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, Class.class, Point.class, Point.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, Class.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(array, Void.class, Point.getInstance(1,1), Point.getInstance(1,1)); }); // Incorrect arity @@ -1960,7 +1960,7 @@ static void testArrayWrongMethodType(Handles hs) throws Throwable { invokeExact(); }); checkWMTE(() -> { // > - boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class, Point.class, Class.class)). + boolean r = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class.asValueType(), Point.class.asValueType(), Class.class)). invokeExact(array, 0, Point.getInstance(1,1), Point.getInstance(1,1), Void.class); }); } @@ -1968,45 +1968,45 @@ static void testArrayWrongMethodType(Handles hs) throws Throwable { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { // Incorrect argument types checkNPE(() -> { // null receiver - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, int.class, Point.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, int.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact((Point[]) null, 0, Point.getInstance(1,1), Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // array reference class - Point x = (Point) hs.get(am, methodType(Point.class, Class.class, int.class, Point.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Class.class, int.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(Void.class, 0, Point.getInstance(1,1), Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // expected reference class - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, int.class, Class.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, int.class, Class.class, Point.class.asValueType())). invokeExact(array, 0, Void.class, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // actual reference class - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, int.class, Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, int.class, Point.class.asValueType(), Class.class)). invokeExact(array, 0, Point.getInstance(1,1), Void.class); }); checkWMTE(() -> { // array primitive class - Point x = (Point) hs.get(am, methodType(Point.class, int.class, int.class, Point.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), int.class, int.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(0, 0, Point.getInstance(1,1), Point.getInstance(1,1)); }); checkWMTE(() -> { // index reference class - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, Class.class, Point.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, Class.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(array, Void.class, Point.getInstance(1,1), Point.getInstance(1,1)); }); // Incorrect return type hs.checkWMTEOrCCE(() -> { // reference class - Void r = (Void) hs.get(am, methodType(Void.class, Point[].class, int.class, Point.class, Point.class)). + Void r = (Void) hs.get(am, methodType(Void.class, Point[].class, int.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(array, 0, Point.getInstance(1,1), Point.getInstance(1,1)); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class, Point.class)). + boolean x = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class.asValueType(), Point.class.asValueType())). invokeExact(array, 0, Point.getInstance(1,1), Point.getInstance(1,1)); }); // Incorrect arity checkWMTE(() -> { // 0 - Point x = (Point) hs.get(am, methodType(Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType())). invokeExact(); }); checkWMTE(() -> { // > - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, int.class, Point.class, Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, int.class, Point.class.asValueType(), Point.class.asValueType(), Class.class)). invokeExact(array, 0, Point.getInstance(1,1), Point.getInstance(1,1), Void.class); }); } @@ -2014,41 +2014,41 @@ static void testArrayWrongMethodType(Handles hs) throws Throwable { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null array - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, int.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, int.class, Point.class.asValueType())). invokeExact((Point[]) null, 0, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // array reference class - Point x = (Point) hs.get(am, methodType(Point.class, Class.class, int.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Class.class, int.class, Point.class.asValueType())). invokeExact(Void.class, 0, Point.getInstance(1,1)); }); hs.checkWMTEOrCCE(() -> { // value reference class - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, int.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, int.class, Class.class)). invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - Point x = (Point) hs.get(am, methodType(Point.class, int.class, int.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), int.class, int.class, Point.class.asValueType())). invokeExact(0, 0, Point.getInstance(1,1)); }); checkWMTE(() -> { // index reference class - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, Class.class, Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, Class.class, Point.class.asValueType())). invokeExact(array, Void.class, Point.getInstance(1,1)); }); // Incorrect return type hs.checkWMTEOrCCE(() -> { // reference class - Void r = (Void) hs.get(am, methodType(Void.class, Point[].class, int.class, Point.class)). + Void r = (Void) hs.get(am, methodType(Void.class, Point[].class, int.class, Point.class.asValueType())). invokeExact(array, 0, Point.getInstance(1,1)); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class)). + boolean x = (boolean) hs.get(am, methodType(boolean.class, Point[].class, int.class, Point.class.asValueType())). invokeExact(array, 0, Point.getInstance(1,1)); }); // Incorrect arity checkWMTE(() -> { // 0 - Point x = (Point) hs.get(am, methodType(Point.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType())). invokeExact(); }); checkWMTE(() -> { // > - Point x = (Point) hs.get(am, methodType(Point.class, Point[].class, int.class, Point.class, Class.class)). + Point x = (Point) hs.get(am, methodType(Point.class.asValueType(), Point[].class, int.class, Point.class.asValueType(), Class.class)). invokeExact(array, 0, Point.getInstance(1,1), Void.class); }); } diff --git a/test/jdk/valhalla/valuetypes/ArrayElementVarHandleTest.java b/test/jdk/valhalla/valuetypes/ArrayElementVarHandleTest.java index a0001ac507b..633111affa1 100644 --- a/test/jdk/valhalla/valuetypes/ArrayElementVarHandleTest.java +++ b/test/jdk/valhalla/valuetypes/ArrayElementVarHandleTest.java @@ -113,7 +113,7 @@ public void testPointRefVarHandle() throws Throwable { public void testPointArrayVarHandle() throws Throwable { // Point[] <: Point.ref[] <: Object Point[] array1 = (Point[]) newArray(Point[].class, POINTS.length); - assertTrue(array1.getClass().componentType() == Point.class); + assertTrue(array1.getClass().componentType() == Point.class.asValueType()); setElements(array1, POINTS); Point[] array3 = new Point[POINTS.length]; @@ -146,7 +146,7 @@ public void testLineRefVarHandle() throws Throwable { @Test public void testLineVarHandle() throws Throwable { Line[] array1 = (Line[])newArray(Line[].class, LINES.length); - assertTrue(array1.getClass().componentType() == Line.class); + assertTrue(array1.getClass().componentType() == Line.class.asValueType()); setElements(array1, LINES); Line[] array3 = new Line[LINES.length]; @@ -159,7 +159,7 @@ public void testLineVarHandle() throws Throwable { @Test public void testNonFlattenedValueVarHandle() throws Throwable { NonFlattenValue[] array1 = (NonFlattenValue[])newArray(NonFlattenValue[].class, NFV_ARRAY.length); - assertTrue(array1.getClass().componentType() == NonFlattenValue.class); + assertTrue(array1.getClass().componentType() == NonFlattenValue.class.asValueType()); setElements(array1, NFV_ARRAY); NonFlattenValue[] array3 = new NonFlattenValue[POINTS.length]; diff --git a/test/jdk/valhalla/valuetypes/BasicTest.java b/test/jdk/valhalla/valuetypes/BasicTest.java index b0f652cc98c..925dafd7c57 100644 --- a/test/jdk/valhalla/valuetypes/BasicTest.java +++ b/test/jdk/valhalla/valuetypes/BasicTest.java @@ -74,7 +74,7 @@ static Point.val toVal(Point.ref o) { @DataProvider(name="constants") static Object[][] constants() { return new Object[][]{ - new Object[] { Point.class, Point.class.asValueType()}, + new Object[] { Point.class, Point.class.asPrimaryType()}, new Object[] { Point.val.class, Point.class.asValueType()}, new Object[] { Point.ref.class, Point.class.asPrimaryType()}, }; @@ -145,21 +145,21 @@ public void testMirrors() { @Test public void testSubtypes() { // Point <: Point.ref and Point <: Object - assertTrue(Point.ref.class.isAssignableFrom(Point.class)); - assertTrue(Object.class.isAssignableFrom(Point.class)); - assertFalse(Point.class.isAssignableFrom(Point.ref.class)); + assertTrue(Point.ref.class.isAssignableFrom(Point.class.asValueType())); + assertTrue(Object.class.isAssignableFrom(Point.class.asValueType())); + assertFalse(Point.class.asValueType().isAssignableFrom(Point.ref.class)); assertTrue(Object.class.isAssignableFrom(Point.ref.class)); - assertTrue(Point.class.asSubclass(Point.ref.class) == Point.class); + assertTrue(Point.class.asValueType().asSubclass(Point.ref.class) == Point.class.asValueType()); try { - Class c = Point.ref.class.asSubclass(Point.class); + Class c = Point.ref.class.asSubclass(Point.class.asValueType()); fail("Point.ref cannot be cast to Point.class"); } catch (ClassCastException e) { } Point o = new Point(10, 20); - assertTrue(Point.class.isInstance(o)); + assertTrue(Point.class.asValueType().isInstance(o)); assertTrue(Point.ref.class.isInstance(o)); - assertFalse(Point.class.isInstance(null)); + assertFalse(Point.class.asValueType().isInstance(null)); assertFalse(Point.ref.class.isInstance(null)); } diff --git a/test/jdk/valhalla/valuetypes/ObjectMethods.java b/test/jdk/valhalla/valuetypes/ObjectMethods.java index 1e1288f77a3..8fc5e3c2dc7 100644 --- a/test/jdk/valhalla/valuetypes/ObjectMethods.java +++ b/test/jdk/valhalla/valuetypes/ObjectMethods.java @@ -156,14 +156,14 @@ public void testToString(Object o) { Object[][] hashcodeTests() { // this is sensitive to the order of the returned fields from Class::getDeclaredFields return new Object[][]{ - { P1, hash(Point.class, 1, 2) }, - { LINE1, hash(Line.class, Point.makePoint(1, 2), Point.makePoint(3, 4)) }, + { P1, hash(Point.class.asValueType(), 1, 2) }, + { LINE1, hash(Line.class.asValueType(), Point.makePoint(1, 2), Point.makePoint(3, 4)) }, { VALUE, hash(hashCodeComponents(VALUE))}, { VALUE1, hash(hashCodeComponents(VALUE1))}, - { Point.makePoint(0,0), hash(Point.class, 0, 0) }, - { Point.default, hash(Point.class, 0, 0) }, - { MyValue1.default, hash(MyValue1.class, Point.default, null) }, - { new MyValue1(0, 0, null), hash(MyValue1.class, Point.makePoint(0,0), null) }, + { Point.makePoint(0,0), hash(Point.class.asValueType(), 0, 0) }, + { Point.default, hash(Point.class.asValueType(), 0, 0) }, + { MyValue1.default, hash(MyValue1.class.asValueType(), Point.default, null) }, + { new MyValue1(0, 0, null), hash(MyValue1.class.asValueType(), Point.makePoint(0,0), null) }, }; } diff --git a/test/jdk/valhalla/valuetypes/PrimitiveTypeConversionTest.java b/test/jdk/valhalla/valuetypes/PrimitiveTypeConversionTest.java index 3d48f69faa5..0e142ee5ca1 100644 --- a/test/jdk/valhalla/valuetypes/PrimitiveTypeConversionTest.java +++ b/test/jdk/valhalla/valuetypes/PrimitiveTypeConversionTest.java @@ -61,8 +61,8 @@ static Value.ref widen(Value v) { @Test public static void primitiveWidening() throws Throwable { MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodHandle mh1 = lookup.findStatic(PrimitiveTypeConversionTest.class, "narrow", methodType(Value.class, Value.ref.class)); - MethodHandle mh2 = mh1.asType(methodType(Value.class, Value.class)); + MethodHandle mh1 = lookup.findStatic(PrimitiveTypeConversionTest.class, "narrow", methodType(Value.class.asValueType(), Value.ref.class)); + MethodHandle mh2 = mh1.asType(methodType(Value.class.asValueType(), Value.class.asValueType())); Object v = mh1.invoke(VALUE); assertEquals(v, VALUE); try { @@ -79,7 +79,7 @@ public static void primitiveWidening() throws Throwable { @Test public static void primitiveNarrowing() throws Throwable { MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodHandle mh = lookup.findStatic(PrimitiveTypeConversionTest.class, "widen", methodType(Value.ref.class, Value.class)); + MethodHandle mh = lookup.findStatic(PrimitiveTypeConversionTest.class, "widen", methodType(Value.ref.class, Value.class.asValueType())); Object v = mh.invoke(VALUE); assertTrue(v == null); try { @@ -88,7 +88,7 @@ public static void primitiveNarrowing() throws Throwable { } catch (NullPointerException e) { e.printStackTrace(); } - MethodHandle mh2 = mh.asType(methodType(Value.class, Value.ref.class)); + MethodHandle mh2 = mh.asType(methodType(Value.class.asValueType(), Value.ref.class)); try { Value v2 = (Value) mh2.invoke((Value.ref)null); fail("Expected NullPointerException but not thrown"); @@ -100,8 +100,8 @@ public static void primitiveNarrowing() throws Throwable { @Test public static void valToRef() throws Throwable { MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodHandle mh1 = lookup.findGetter(Value.class, "val", Point.class); - MethodHandle mh2 = mh1.asType(methodType(Point.ref.class, Value.class)); + MethodHandle mh1 = lookup.findGetter(Value.class.asValueType(), "val", Point.class.asValueType()); + MethodHandle mh2 = mh1.asType(methodType(Point.ref.class, Value.class.asValueType())); Value v = new Value(new Point(10,10), null); Point p1 = (Point) mh1.invokeExact(VALUE); @@ -111,8 +111,8 @@ public static void valToRef() throws Throwable { @Test public static void refToVal() throws Throwable { - MethodHandle mh1 = MethodHandles.lookup().findGetter(Value.class, "ref", Point.ref.class); - MethodHandle mh2 = mh1.asType(methodType(Point.class, Value.class)); + MethodHandle mh1 = MethodHandles.lookup().findGetter(Value.class.asValueType(), "ref", Point.ref.class); + MethodHandle mh2 = mh1.asType(methodType(Point.class.asValueType(), Value.class.asValueType())); Point.ref p1 = (Point.ref) mh1.invokeExact(VALUE); Point p2 = (Point) mh2.invokeExact(VALUE); assertEquals(p1, p2); @@ -121,8 +121,8 @@ public static void refToVal() throws Throwable { @Test public static void valToRef1() throws Throwable { MethodHandles.Lookup lookup = MethodHandles.lookup(); - MethodHandle mh1 = lookup.findGetter(Value.class, "val", Point.class); - MethodHandle mh2 = mh1.asType(methodType(Point.class, Value.ref.class)); + MethodHandle mh1 = lookup.findGetter(Value.class.asValueType(), "val", Point.class.asValueType()); + MethodHandle mh2 = mh1.asType(methodType(Point.class.asValueType(), Value.ref.class)); Point p1 = (Point) mh1.invokeExact(VALUE); Point p2 = (Point) mh2.invoke(VALUE); @@ -133,7 +133,7 @@ public static void valToRef1() throws Throwable { @Test public static void refToVal1() throws Throwable { - MethodHandle mh1 = MethodHandles.lookup().findGetter(Value.class, "ref", Point.ref.class); + MethodHandle mh1 = MethodHandles.lookup().findGetter(Value.class.asValueType(), "ref", Point.ref.class); MethodHandle mh2 = mh1.asType(methodType(Point.ref.class, Value.ref.class)); Value v = new Value(new Point(10,10), null); @@ -146,8 +146,8 @@ public static void refToVal1() throws Throwable { @Test public static void refToVal2() throws Throwable { - MethodHandle mh1 = MethodHandles.lookup().findGetter(Value.class, "ref", Point.ref.class); - MethodHandle mh2 = mh1.asType(methodType(Point.class, Value.class)); + MethodHandle mh1 = MethodHandles.lookup().findGetter(Value.class.asValueType(), "ref", Point.ref.class); + MethodHandle mh2 = mh1.asType(methodType(Point.class.asValueType(), Value.class.asValueType())); Value v = new Value(new Point(10,10), null); Point.ref p1 = (Point.ref) mh1.invokeExact(v); diff --git a/test/jdk/valhalla/valuetypes/QTypeDescriptorTest.java b/test/jdk/valhalla/valuetypes/QTypeDescriptorTest.java index be6beecfafc..67807dd36b8 100644 --- a/test/jdk/valhalla/valuetypes/QTypeDescriptorTest.java +++ b/test/jdk/valhalla/valuetypes/QTypeDescriptorTest.java @@ -59,8 +59,8 @@ public void testLambda() { @Test public void testMethodInvoke() throws Exception { - Class pointQType = Point.class; - Class nonFlattenValueQType = NonFlattenValue.class; + Class pointQType = Point.class.asValueType(); + Class nonFlattenValueQType = NonFlattenValue.class.asValueType(); Method m = QTypeDescriptorTest.class .getDeclaredMethod("toLine", pointQType, nonFlattenValueQType); makeLine(m, P0, NFV); @@ -126,13 +126,13 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl @DataProvider static Object[][] descriptors() { return new Object[][]{ - { QTypeDescriptorTest.class, "toLine", new Class[] { Point.class, NonFlattenValue.class}, true}, - { QTypeDescriptorTest.class, "toLine", new Class[] { Point.ref.class, NonFlattenValue.class}, false}, + { QTypeDescriptorTest.class, "toLine", new Class[] { Point.class.asValueType(), NonFlattenValue.class.asValueType()}, true}, + { QTypeDescriptorTest.class, "toLine", new Class[] { Point.ref.class, NonFlattenValue.class.asValueType()}, false}, { QTypeDescriptorTest.class, "toLine", new Class[] { Point[].class }, true}, - { NonFlattenValue.class, "point", null, true}, - { NonFlattenValue.class, "pointValue", null, true}, - { NonFlattenValue.class, "has", new Class[] { Point.class, Point.ref.class}, true}, - { NonFlattenValue.class, "has", new Class[] { Point.class, Point.class}, false}, + { NonFlattenValue.class.asValueType(), "point", null, true}, + { NonFlattenValue.class.asValueType(), "pointValue", null, true}, + { NonFlattenValue.class.asValueType(), "has", new Class[] { Point.class.asValueType(), Point.ref.class}, true}, + { NonFlattenValue.class.asValueType(), "has", new Class[] { Point.class.asValueType(), Point.class.asValueType()}, false}, }; } @@ -151,11 +151,11 @@ static Object[][] methodTypes() { ClassLoader loader = QTypeDescriptorTest.class.getClassLoader(); return new Object[][]{ { "point", MethodType.methodType(Point.ref.class), true }, - { "pointValue", MethodType.methodType(Point.class), true }, - { "has", MethodType.methodType(boolean.class, Point.class, Point.ref.class), true }, - { "point", MethodType.methodType(Point.class), false }, + { "pointValue", MethodType.methodType(Point.class.asValueType()), true }, + { "has", MethodType.methodType(boolean.class, Point.class.asValueType(), Point.ref.class), true }, + { "point", MethodType.methodType(Point.class.asValueType()), false }, { "pointValue", MethodType.methodType(Point.ref.class), false }, - { "has", MethodType.methodType(boolean.class, Point.ref.class, Point.class), false }, + { "has", MethodType.methodType(boolean.class, Point.ref.class, Point.class.asValueType()), false }, { "point", MethodType.fromMethodDescriptorString("()LPoint;", loader), true }, { "point", MethodType.fromMethodDescriptorString("()QPoint;", loader), false }, { "pointValue", MethodType.fromMethodDescriptorString("()QPoint;", loader), true }, @@ -168,7 +168,7 @@ static Object[][] methodTypes() { @Test(dataProvider = "methodTypes") public void methodHandleLookup(String name, MethodType mtype, boolean found) throws Throwable { try { - MethodHandles.lookup().findVirtual(NonFlattenValue.class, name, mtype); + MethodHandles.lookup().findVirtual(NonFlattenValue.class.asValueType(), name, mtype); if (!found) throw new AssertionError("Expected NoSuchMethodException"); } catch (NoSuchMethodException e) { if (found) throw e; diff --git a/test/jdk/valhalla/valuetypes/Reflection.java b/test/jdk/valhalla/valuetypes/Reflection.java index 1050a60872a..b0ec112e429 100644 --- a/test/jdk/valhalla/valuetypes/Reflection.java +++ b/test/jdk/valhalla/valuetypes/Reflection.java @@ -41,7 +41,7 @@ public class Reflection { @Test public static void testPointClass() throws Exception { - Object o = Point.class.newInstance(); + Object o = Point.class.asValueType().newInstance(); assertEquals(o.getClass(), Point.class.asPrimaryType()); Constructor ctor = Point.class.getDeclaredConstructor(int.class, int.class); @@ -68,18 +68,18 @@ public static void testPointClass() throws Exception { @Test public static void testLineClass() throws Exception { - checkInstanceField(Line.class, "p1", Point.class); - checkInstanceField(Line.class, "p2", Point.class); - checkInstanceMethod(Line.class, "p1", Point.class); - checkInstanceMethod(Line.class, "p2", Point.class); + checkInstanceField(Line.class.asValueType(), "p1", Point.class.asValueType()); + checkInstanceField(Line.class.asValueType(), "p2", Point.class.asValueType()); + checkInstanceMethod(Line.class.asValueType(), "p1", Point.class.asValueType()); + checkInstanceMethod(Line.class.asValueType(), "p2", Point.class.asValueType()); } @Test public static void testNonFlattenValue() throws Exception { - checkInstanceField(NonFlattenValue.class, "nfp", Point.ref.class); - checkInstanceMethod(NonFlattenValue.class, "pointValue", Point.class); - checkInstanceMethod(NonFlattenValue.class, "point", Point.ref.class); - checkInstanceMethod(NonFlattenValue.class, "has", boolean.class, Point.class, Point.ref.class); + checkInstanceField(NonFlattenValue.class.asValueType(), "nfp", Point.ref.class); + checkInstanceMethod(NonFlattenValue.class.asValueType(), "pointValue", Point.class.asValueType()); + checkInstanceMethod(NonFlattenValue.class.asValueType(), "point", Point.ref.class); + checkInstanceMethod(NonFlattenValue.class.asValueType(), "has", boolean.class, Point.class.asValueType(), Point.ref.class); } diff --git a/test/jdk/valhalla/valuetypes/StaticFactoryMethodHandleTest.java b/test/jdk/valhalla/valuetypes/StaticFactoryMethodHandleTest.java index b9189274fa9..41adbe33724 100644 --- a/test/jdk/valhalla/valuetypes/StaticFactoryMethodHandleTest.java +++ b/test/jdk/valhalla/valuetypes/StaticFactoryMethodHandleTest.java @@ -64,34 +64,34 @@ private ConstructorWithArgs(int x, int y, int z) { public static void main(String... args) throws Throwable { // test default static init factory - MethodType mtype0 = MethodType.methodType(DefaultConstructor.class); - MethodHandle mh0 = staticInitFactory(DefaultConstructor.class, mtype0); + MethodType mtype0 = MethodType.methodType(DefaultConstructor.class.asValueType()); + MethodHandle mh0 = staticInitFactory(DefaultConstructor.val.class, mtype0); DefaultConstructor o0 = (DefaultConstructor)mh0.invokeExact(); assertEquals(o0, new DefaultConstructor()); - assertEquals(o0, newInstance(DefaultConstructor.class, 0, mh0.type().parameterArray())); + assertEquals(o0, newInstance(DefaultConstructor.val.class, 0, mh0.type().parameterArray())); // test 1-arg static init factory - MethodType mtype1 = MethodType.methodType(ConstructorWithArgs.class, int.class); - MethodHandle mh1 = staticInitFactory(ConstructorWithArgs.class, mtype1); + MethodType mtype1 = MethodType.methodType(ConstructorWithArgs.class.asValueType(), int.class); + MethodHandle mh1 = staticInitFactory(ConstructorWithArgs.val.class, mtype1); ConstructorWithArgs o1 = (ConstructorWithArgs)mh1.invokeExact(1); assertEquals(o1, new ConstructorWithArgs(1)); - assertEquals(o1, newInstance(ConstructorWithArgs.class, Modifier.PUBLIC, mh1.type().parameterArray(), 1)); + assertEquals(o1, newInstance(ConstructorWithArgs.val.class, Modifier.PUBLIC, mh1.type().parameterArray(), 1)); // test 2-arg static init factory - MethodType mtype2 = MethodType.methodType(ConstructorWithArgs.class, int.class, int.class); - MethodHandle mh2 = staticInitFactory(ConstructorWithArgs.class, mtype2); + MethodType mtype2 = MethodType.methodType(ConstructorWithArgs.class.asValueType(), int.class, int.class); + MethodHandle mh2 = staticInitFactory(ConstructorWithArgs.val.class, mtype2); ConstructorWithArgs o2 = (ConstructorWithArgs)mh2.invokeExact(1, 2); assertEquals(o2, new ConstructorWithArgs(1, 2)); - assertEquals(o2, newInstance(ConstructorWithArgs.class, 0, mh2.type().parameterArray(), 1, 2)); + assertEquals(o2, newInstance(ConstructorWithArgs.val.class, 0, mh2.type().parameterArray(), 1, 2)); // test 3-arg static init factory - MethodType mtype3 = MethodType.methodType(ConstructorWithArgs.class, int.class, int.class, int.class); - MethodHandle mh3 = staticInitFactory(ConstructorWithArgs.class, mtype3); + MethodType mtype3 = MethodType.methodType(ConstructorWithArgs.class.asValueType(), int.class, int.class, int.class); + MethodHandle mh3 = staticInitFactory(ConstructorWithArgs.val.class, mtype3); ConstructorWithArgs o3 = (ConstructorWithArgs)mh3.invokeExact(1, 2, 3); assertEquals(o3, new ConstructorWithArgs(1, 2, 3)); - assertEquals(o3, newInstance(ConstructorWithArgs.class, Modifier.PRIVATE, mh3.type().parameterArray(), 1, 2, 3)); + assertEquals(o3, newInstance(ConstructorWithArgs.val.class, Modifier.PRIVATE, mh3.type().parameterArray(), 1, 2, 3)); } /* @@ -108,7 +108,7 @@ static MethodHandle staticInitFactory(Class c, MethodType mtype) // MethodHandle mh = lookup.findStatic(c, "", mtype); try { - lookup.findConstructor(DefaultConstructor.class, mtype); + lookup.findConstructor(DefaultConstructor.class.asValueType(), mtype); throw new RuntimeException("findConstructor should not find the static init factory"); } catch (NoSuchMethodException e) { } diff --git a/test/jdk/valhalla/valuetypes/StaticFactoryTest.java b/test/jdk/valhalla/valuetypes/StaticFactoryTest.java index b6e85edbd46..0afdf5177c3 100644 --- a/test/jdk/valhalla/valuetypes/StaticFactoryTest.java +++ b/test/jdk/valhalla/valuetypes/StaticFactoryTest.java @@ -53,7 +53,7 @@ public SimplePrimitive(int x) { } } - static final Class PRIMITIVE_TYPE = SimplePrimitive.class; + static final Class PRIMITIVE_TYPE = SimplePrimitive.class.asValueType(); @Test public static void testPrimitiveClassConstructor() throws Exception { diff --git a/test/jdk/valhalla/valuetypes/UninitializedValueTest.java b/test/jdk/valhalla/valuetypes/UninitializedValueTest.java index 925e1acd475..5e9974891b8 100644 --- a/test/jdk/valhalla/valuetypes/UninitializedValueTest.java +++ b/test/jdk/valhalla/valuetypes/UninitializedValueTest.java @@ -76,7 +76,7 @@ public void testValue() throws ReflectiveOperationException { // field of primitive value type must be non-null Field f1 = v.getClass().getDeclaredField("empty"); - assertTrue(f1.getType() == EmptyValue.class); + assertTrue(f1.getType() == EmptyValue.class.asValueType()); EmptyValue empty = (EmptyValue)f1.get(v); assertTrue(empty.isEmpty()); // test if empty is non-null with default value } @@ -90,12 +90,12 @@ public void testMutableValue() throws ReflectiveOperationException { // field of primitive value type type must be non-null Field f1 = v.getClass().getDeclaredField("empty"); - assertTrue(f1.getType() == EmptyValue.class); + assertTrue(f1.getType() == EmptyValue.class.asValueType()); EmptyValue empty = (EmptyValue)f1.get(v); assertTrue(empty.isEmpty()); // test if empty is non-null with default value Field f2 = v.getClass().getDeclaredField("vempty"); - assertTrue(f2.getType() == EmptyValue.class); + assertTrue(f2.getType() == EmptyValue.class.asValueType()); EmptyValue vempty = (EmptyValue)f2.get(v); assertTrue(vempty.isEmpty()); // test if vempty is non-null with default value @@ -108,7 +108,7 @@ public void testMutableValue() throws ReflectiveOperationException { @Test public void testMethodHandleValue() throws Throwable { Value v = new Value(); - MethodHandle mh = MethodHandles.lookup().findGetter(Value.class, "empty", EmptyValue.class); + MethodHandle mh = MethodHandles.lookup().findGetter(Value.class.asValueType(), "empty", EmptyValue.class.asValueType()); EmptyValue empty = (EmptyValue) mh.invokeExact(v); assertTrue(empty.isEmpty()); // test if empty is non-null with default value } @@ -116,20 +116,20 @@ public void testMethodHandleValue() throws Throwable { @Test public void testMethodHandleMutableValue() throws Throwable { MutableValue v = new MutableValue(); - MethodHandle getter = MethodHandles.lookup().findGetter(MutableValue.class, "empty", EmptyValue.class); + MethodHandle getter = MethodHandles.lookup().findGetter(MutableValue.class, "empty", EmptyValue.class.asValueType()); EmptyValue empty = (EmptyValue) getter.invokeExact(v); assertTrue(empty.isEmpty()); // test if empty is non-null with default value - MethodHandle getter1 = MethodHandles.lookup().findGetter(MutableValue.class, "vempty", EmptyValue.class); + MethodHandle getter1 = MethodHandles.lookup().findGetter(MutableValue.class, "vempty", EmptyValue.class.asValueType()); EmptyValue vempty = (EmptyValue) getter1.invokeExact(v); assertTrue(vempty.isEmpty()); // test if vempty is non-null with default value - MethodHandle setter = MethodHandles.lookup().findSetter(MutableValue.class, "empty", EmptyValue.class); + MethodHandle setter = MethodHandles.lookup().findSetter(MutableValue.class, "empty", EmptyValue.class.asValueType()); setter.invokeExact(v, new EmptyValue()); empty = (EmptyValue) getter.invokeExact(v); assertTrue(empty == new EmptyValue()); - MethodHandle setter1 = MethodHandles.lookup().findSetter(MutableValue.class, "vempty", EmptyValue.class); + MethodHandle setter1 = MethodHandles.lookup().findSetter(MutableValue.class, "vempty", EmptyValue.class.asValueType()); setter1.invokeExact(v, new EmptyValue()); vempty = (EmptyValue) getter1.invokeExact(v); assertTrue(vempty == new EmptyValue()); @@ -152,7 +152,7 @@ public void nonNullableField_reflection() throws ReflectiveOperationException { @Test(expectedExceptions = { NullPointerException.class}) public void nonNullableField_MethodHandle() throws Throwable { MutableValue v = new MutableValue(); - MethodHandle mh = MethodHandles.lookup().findSetter(MutableValue.class, "empty", EmptyValue.class); + MethodHandle mh = MethodHandles.lookup().findSetter(MutableValue.class, "empty", EmptyValue.class.asValueType()); EmptyValue.ref e = null; EmptyValue empty = (EmptyValue) mh.invokeExact(v, (EmptyValue)e); } diff --git a/test/jdk/valhalla/valuetypes/ValueArray.java b/test/jdk/valhalla/valuetypes/ValueArray.java index 8111baeffaf..9521328bda9 100644 --- a/test/jdk/valhalla/valuetypes/ValueArray.java +++ b/test/jdk/valhalla/valuetypes/ValueArray.java @@ -39,7 +39,7 @@ public class ValueArray { @DataProvider(name="elementTypes") static Object[][] elementTypes() { return new Object[][]{ - new Object[] { Point.class, new Point(0,0) }, + new Object[] { Point.class.asValueType(), new Point(0,0) }, new Object[] { Point.ref.class, null }, }; } diff --git a/test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java b/test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java index 14dce3f1a04..44258962e30 100644 --- a/test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java +++ b/test/jdk/valhalla/valuetypes/ValueBootstrapMethods.java @@ -54,7 +54,7 @@ public static void main(String... args) throws Throwable { Class test = valueTestClass(); Value value = new Value(10, 5.03, "foo", "bar", "goo"); - Class valueClass = Value.class; + Class valueClass = Value.class.asValueType(); Method hashCode = test.getMethod("hashCode", valueClass); int hash = (int)hashCode.invoke(null, value); assertEquals(hash, value.localHashCode()); @@ -80,7 +80,7 @@ public static primitive class Value { } List values() { - return List.of(Value.class, i, d, s, l); + return List.of(Value.class.asValueType(), i, d, s, l); } public int localHashCode() { @@ -93,7 +93,7 @@ public int localHashCode() { */ private static Class valueTestClass() throws Exception { Path path = Paths.get(TEST_CLASSES, "ValueTest.class"); - generate(Value.class, "ValueTest", path); + generate(Value.class.asValueType(), "ValueTest", path); return Class.forName("ValueTest"); } diff --git a/test/jdk/valhalla/valuetypes/ValueConstantDesc.java b/test/jdk/valhalla/valuetypes/ValueConstantDesc.java index 7ad7d77b714..91d9c7abeb6 100644 --- a/test/jdk/valhalla/valuetypes/ValueConstantDesc.java +++ b/test/jdk/valhalla/valuetypes/ValueConstantDesc.java @@ -43,7 +43,7 @@ public class ValueConstantDesc { @DataProvider(name="descs") static Object[][] descs() { return new Object[][]{ - new Object[] { Point.class, ClassDesc.ofDescriptor("Q" + NAME + ";"), NAME}, + new Object[] { Point.class.asValueType(), ClassDesc.ofDescriptor("Q" + NAME + ";"), NAME}, new Object[] { Point.ref.class, ClassDesc.ofDescriptor("L" + NAME + ";"), NAME}, new Object[] { Point[].class, ClassDesc.ofDescriptor("[Q" + NAME + ";"), NAME + "[]"}, new Object[] { Point.ref[][].class, ClassDesc.ofDescriptor("[[L" + NAME + ";"), NAME + "[][]"}, @@ -68,7 +68,7 @@ public void classDesc(Class type, ClassDesc expected, String displayName) { @DataProvider(name="componentTypes") static Object[][] componentTypes() { return new Object[][]{ - new Object[] { Point.class }, + new Object[] { Point.class.asValueType() }, new Object[] { Point.ref.class } }; } @@ -88,7 +88,7 @@ public void arrayType(Class componentType) { @DataProvider(name="valueDesc") static Object[][] valueDesc() { return new Object[][]{ - new Object[] { Point.class, "Q" + NAME + ";"}, + new Object[] { Point.class.asValueType(), "Q" + NAME + ";"}, new Object[] { Point.ref.class, "L" + NAME + ";"}, new Object[] { Point[].class, "[Q" + NAME + ";"}, new Object[] { Point.ref[][].class, "[[L" + NAME + ";"}, diff --git a/test/langtools/tools/javac/valhalla/lworld-values/ClassLiteralTypingNegativeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/ClassLiteralTypingNegativeTest.java index 50491453c2d..c6ab7a63616 100644 --- a/test/langtools/tools/javac/valhalla/lworld-values/ClassLiteralTypingNegativeTest.java +++ b/test/langtools/tools/javac/valhalla/lworld-values/ClassLiteralTypingNegativeTest.java @@ -11,7 +11,7 @@ public static primitive class Foo { final int value = 0; public static void main(String[] args) { - Class cFooRef = Foo.class; // Error + Class cFooRef = Foo.class.asValueType(); // Error cFooRef = new Foo().getClass(); // Error cFooRef = Foo.ref.class; // OK. cFooRef = Foo.val.class; // Error. @@ -28,7 +28,7 @@ public static primitive class Bar implements I { final int value = 0; public static void main(String[] args) { - Class cBarRef = Bar.class; // Error + Class cBarRef = Bar.class.asValueType(); // Error cBarRef = new Bar().getClass(); // Error cBarRef = Bar.ref.class; // OK. cBarRef = Bar.val.class; // Error. diff --git a/test/langtools/tools/javac/valhalla/lworld-values/ClassLiteralTypingNegativeTest.out b/test/langtools/tools/javac/valhalla/lworld-values/ClassLiteralTypingNegativeTest.out index 7f54c390659..e47ed7d8318 100644 --- a/test/langtools/tools/javac/valhalla/lworld-values/ClassLiteralTypingNegativeTest.out +++ b/test/langtools/tools/javac/valhalla/lworld-values/ClassLiteralTypingNegativeTest.out @@ -1,8 +1,8 @@ -ClassLiteralTypingNegativeTest.java:14:51: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) +ClassLiteralTypingNegativeTest.java:14:69: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) ClassLiteralTypingNegativeTest.java:15:41: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) ClassLiteralTypingNegativeTest.java:17:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) ClassLiteralTypingNegativeTest.java:19:34: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) -ClassLiteralTypingNegativeTest.java:31:51: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) +ClassLiteralTypingNegativeTest.java:31:69: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) ClassLiteralTypingNegativeTest.java:32:41: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) ClassLiteralTypingNegativeTest.java:34:30: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) ClassLiteralTypingNegativeTest.java:36:34: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Class, java.lang.Class) diff --git a/test/langtools/tools/javac/valhalla/lworld-values/TestReflectiveMirrors.java b/test/langtools/tools/javac/valhalla/lworld-values/TestReflectiveMirrors.java new file mode 100644 index 00000000000..78466fb5e1f --- /dev/null +++ b/test/langtools/tools/javac/valhalla/lworld-values/TestReflectiveMirrors.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2021, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * 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. + */ + +/* + * @test + * @bug 8269956 + * @summary javac should generate `ldc LPoint;` for class literal Point.class + * @run main TestReflectiveMirrors + */ + +public class TestReflectiveMirrors { + + static primitive class RefDefault.val {} + static primitive class ValDefault {} + + public static void main(String [] args) { + + if (RefDefault.class != new RefDefault().getClass()) { + throw new AssertionError("Wrong mirror"); + } + + if (RefDefault.ref.class != new RefDefault().getClass()) { + throw new AssertionError("Wrong mirror"); + } + + if (RefDefault.val.class != new RefDefault().getClass().asValueType()) { + throw new AssertionError("Wrong mirror"); + } + + if (ValDefault.class != new ValDefault().getClass()) { + throw new AssertionError("Wrong mirror"); + } + + if (ValDefault.ref.class != new ValDefault().getClass()) { + throw new AssertionError("Wrong mirror"); + } + + if (ValDefault.val.class != new ValDefault().getClass().asValueType()) { + throw new AssertionError("Wrong mirror"); + } + + if (TestReflectiveMirrors.RefDefault.class != new RefDefault().getClass()) { + throw new AssertionError("Wrong mirror"); + } + + if (TestReflectiveMirrors.RefDefault.ref.class != new RefDefault().getClass()) { + throw new AssertionError("Wrong mirror"); + } + + if (TestReflectiveMirrors.RefDefault.val.class != new RefDefault().getClass().asValueType()) { + throw new AssertionError("Wrong mirror"); + } + + if (TestReflectiveMirrors.ValDefault.class != new ValDefault().getClass()) { + throw new AssertionError("Wrong mirror"); + } + + if (TestReflectiveMirrors.ValDefault.ref.class != new ValDefault().getClass()) { + throw new AssertionError("Wrong mirror"); + } + + if (TestReflectiveMirrors.ValDefault.val.class != new ValDefault().getClass().asValueType()) { + throw new AssertionError("Wrong mirror"); + } + } +} diff --git a/test/langtools/tools/javac/valhalla/lworld-values/UnifiedPrimitiveClassBytecodeTest.java b/test/langtools/tools/javac/valhalla/lworld-values/UnifiedPrimitiveClassBytecodeTest.java index 41503f4d2f1..c9d6354dbab 100644 --- a/test/langtools/tools/javac/valhalla/lworld-values/UnifiedPrimitiveClassBytecodeTest.java +++ b/test/langtools/tools/javac/valhalla/lworld-values/UnifiedPrimitiveClassBytecodeTest.java @@ -46,7 +46,7 @@ public void foo(X.ref[] xra, X[] xa) { xra = new X.ref[10]; xra[0] = xa[0]; xa[1] = xra[0]; - Class c = X.class; + Class c = X.val.class; c = X.ref.class; } } diff --git a/test/langtools/tools/javac/valhalla/lworld-values/ValueBootstrapMethodsTest.java b/test/langtools/tools/javac/valhalla/lworld-values/ValueBootstrapMethodsTest.java index e74164a0cab..7872fdcd4bf 100644 --- a/test/langtools/tools/javac/valhalla/lworld-values/ValueBootstrapMethodsTest.java +++ b/test/langtools/tools/javac/valhalla/lworld-values/ValueBootstrapMethodsTest.java @@ -46,7 +46,7 @@ public static final primitive class Value { } private List values() { - return List.of(Value.class, i, d, s, l); + return List.of(Value.class.asValueType(), i, d, s, l); } public int localHashCode() { @@ -55,7 +55,7 @@ public int localHashCode() { public String localToString() { System.out.println(l); - return String.format("%s@%s", Value.class.getName(), Integer.toHexString(localHashCode())); + return String.format("%s@%s", Value.class.asValueType().getName(), Integer.toHexString(localHashCode())); } @Override