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

Metafactory crashes on code with method reference

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 8
    • 8, 8-repo-lambda
    • tools
    • b108
    • Verified

      The following program

      class CrashWithException {
          private static <T> void test(T arg) {
              Function<Class<T>,Field[]> firstFunction = Class<T>::getFields;
          }
          public static void main(String... args) {
              test("Hello World");
          }
      }

      Crashes at runtime:

      Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
          at java.lang.invoke.CallSite.makeSite(CallSite.java:298)
          at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:295)
          at CrashWithException.test(CrashWithException.java)
          at CrashWithException.main(CrashWithException.java:12)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:491)
          at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
      Caused by: java.lang.IllegalArgumentException: not a direct method handle
          at java.lang.invoke.MethodHandleInfo.<init>(MethodHandleInfo.java:52)
          at java.lang.invoke.AbstractValidatingLambdaMetafactory.<init>(AbstractValidatingLambdaMetafactory.java:125)
          at java.lang.invoke.InnerClassLambdaMetafactory.<init>(InnerClassLambdaMetafactory.java:126)
          at java.lang.invoke.LambdaMetafactory.metaFactory(LambdaMetafactory.java:207)
          at java.lang.invoke.CallSite.makeSite(CallSite.java:283)
          ... 8 more

            rfield Robert Field (Inactive)
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: