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

BootstrapMethodError is thrown for method reference with intersection type bound

XMLWordPrintable

      BootstrapMethodError is thrown for the following code:

      interface Fun {
          <T extends String & Runnable> String m(T p);
      }

      class A {
          public static <S extends Runnable> String methodS(S a) {
              return null;
          }

      }

      public class Test {
          public static void main(String argv[]) {
              Fun f = A::methodS;
          }
      }


      Exception in thread "main" java.lang.BootstrapMethodError: call site initialization exception
      at java.lang.invoke.CallSite.makeSite(CallSite.java:328)
      at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:307)
      at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:297)
      at Test.main(Test.java:14)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:484)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
      Caused by: java.lang.invoke.LambdaConversionException: Type mismatch for lambda argument 0: class java.lang.String is not convertible to interface java.lang.Runnable
      at java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:267)
      at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:303)
      at java.lang.invoke.CallSite.makeSite(CallSite.java:289)
      ... 8 more

            sadayapalam Srikanth Adayapalam (Inactive)
            vrudomet Victor Rudometov
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: