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

ClassCastException with no stack trace is thrown with -Xcomp in method handle invocation

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b29

      Backports

        Description

        Constructor0204 test expects IllegalArgumentException thrown due to wrong parameter type, something like this:

          Class params[] = {int.class};
          Constructor c = T.class.getConstructor( params );
          Object args[] = {int.class};
          T ob = (T) (c.newInstance( args ));

        But VM throws ClassCastException with no stack trace during the invocation of a method handle when running with -Xcomp in the new core reflection implementation after JEP 416 is integrated. InvocationTargetException wrapping CCE is thrown instead.

        Constructor0204: Failed. Constructor0204: unexpected java.lang.reflect.InvocationTargetException thrown

        java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:72)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)
        at javasoft.sqe.tests.api.java.lang.reflect.Constructor.CNewInstanceTests.Constructor0204(CNewInstanceTests.java:167)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:577)
        at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:406)
        at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:577)
        at com.sun.jck.lib.ExecJCKTestSameJVMCmd$Version2Test.execute(ExecJCKTestSameJVMCmd.java:603)
        at com.sun.jck.lib.ExecJCKTestSameJVMCmd$StandardTest.run(ExecJCKTestSameJVMCmd.java:560)
        at com.sun.jck.lib.ExecJCKTestSameJVMCmd.execute(ExecJCKTestSameJVMCmd.java:444)
        at com.sun.jck.lib.ExecJCKTestSameJVMCmd.run(ExecJCKTestSameJVMCmd.java:374)
        at com.sun.jck.lib.ExecInSeparateThreadCmd$StatusCallable.call(ExecInSeparateThreadCmd.java:76)
        at com.sun.jck.lib.ExecInSeparateThreadCmd$StatusCallable.call(ExecInSeparateThreadCmd.java:60)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.lang.Thread.run(Thread.java:833)
        Caused by: java.lang.ClassCastException

          Attachments

          1. Test.java
            0.4 kB
          2. 8277964.patch
            7 kB
          3. IllegalArgumentsTest.java
            4 kB

            Issue Links

              Activity

                People

                Assignee:
                kvn Vladimir Kozlov
                Reporter:
                mchung Mandy Chung
                Votes:
                0 Vote for this issue
                Watchers:
                15 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: