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

[lworld] LambdaMetaFactory should allow an inline value projection type to convert to its reference projection type

    XMLWordPrintable

    Details

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

      Description

      Reported by Maurizio:

      This program compiles:

      import java.util.function.ToIntFunction;

      public class TestBug {

          static class c_int { }
          static inline class Pointer<X> {
              final long addr;

              public Pointer(long addr) {
                  this.addr = addr;
              }
          }

          public static void main(String[] args) {
              Pointer<c_int> p_int = new Pointer<>(12);
              doAction(p_int, TestBug::one);
              doAction(p_int, TestBug::two);
          }

          static <Z> void doAction(Pointer<Z> pointer, ToIntFunction<Pointer.ref<Z>> action) { }

          static int one(Pointer<c_int> pointer) {
              return 1;
          }

          static int two(Pointer<c_int> p_int) {
              return 2;
          }
      }

      but when run fails with an exception:

      Exception in thread "main" java.lang.BootstrapMethodError: bootstrap method initialization exception
          at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:194)
          at java.base/java.lang.invoke.CallSite.makeSite(CallSite.java:315)
          at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:259)
          at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:249)
          at api.TestBug.main(TestBug.java:18)
      Caused by: java.lang.invoke.LambdaConversionException: Type mismatch for lambda argument 0: class api.TestBug$Pointer$ref is not convertible to inline class api.TestBug$Pointer
          at java.base/java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:279)
          at java.base/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:327)
          at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:127)
          ... 4 more

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mchung Mandy Chung
              Reporter:
              sadayapalam Srikanth Adayapalam
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: