Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8214488

[LW2] Lookup should fail if the method type does not match

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: repo-valhalla
    • Fix Version/s: repo-valhalla
    • Component/s: core-libs
    • Labels:

      Description

      Under test/hotspot/jtreg/compiler/valhalla/valuetypes/TestNullableValueTypes.java, need to investigate the following:

      MethodType test19_mt = MethodType.methodType(void.class, MyValue1.class);
      ==> test19_target1 and test19_target2 takes QType but the lookup succeeds. I expect it should fail.

      test19_mh1 = lookup.findStatic(clazz, "test19_target1", test19_mt);
      test19_mh2 = lookup.findStatic(clazz, "test19_target2", test19_mt);


          public void test19() throws Throwable {
              test19_mh1.invokeExact(nullValue);
              test19_mh2.invokeExact(nullValue);
          }

          static MethodHandle test19_mh1;
          static MethodHandle test19_mh2;

          @DontInline
          static void test19_target1(MyValue1 vt) {
              nullValue = vt;
          }

          @ForceInline
          static void test19_target2(MyValue1 vt) {
              nullValue = vt;
          }

      If the lookup method type changes to MyValue1.class.asValueType(), it fails at link time as nullValue is a box type instead.

      Exception in thread "main" java.lang.reflect.InvocationTargetException
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.base/java.lang.reflect.Method.invoke(Method.java:568)
              at compiler.valhalla.valuetypes.ValueTypeTest.run(ValueTypeTest.java:515)
              at compiler.valhalla.valuetypes.ValueTypeTest.run(ValueTypeTest.java:305)
              at compiler.valhalla.valuetypes.TestNullableValueTypes.main(TestNullableValueTypes.java:64)
      Caused by: java.lang.RuntimeException: test19 failed
              at compiler.valhalla.valuetypes.TestNullableValueTypes.test19_verifier(TestNullableValueTypes.java:561)
              ... 7 more
      Caused by: java.lang.invoke.WrongMethodTypeException: expected (MyValue1)void but found (MyValue1.box)void
              at java.base/java.lang.invoke.Invokers.newWrongMethodTypeException(Invokers.java:476)
              at java.base/java.lang.invoke.Invokers.checkExactType(Invokers.java:485)
              at compiler.valhalla.valuetypes.TestNullableValueTypes.test19(TestNullableValueTypes.java:552)
              at compiler.valhalla.valuetypes.TestNullableValueTypes.test19_verifier(TestNullableValueTypes.java:559)
              ... 7 more
      ]
       exitValue = 1

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mchung Mandy Chung
                Reporter:
                mchung Mandy Chung
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: