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

LambdaMetafactory with invokespecial causes VerificationError

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 17
    • Component/s: core-libs
    • Labels:
      None

      Description

      Passing an 'invokespecial' MethodHandle to LambdaMetafactory—for example, 'invokespecial Object.toString:()Ljava/lang/String'—causes an internal VerificationError, because the lambda class, a nestmate of the original class, does not have access to use invokespecial on the original class's super methods.

      java.lang.InternalError: java.lang.VerifyError: Bad type on operand stack
      Exception Details:
        Location:
          MetafactoryArgValidationTest$C$$Lambda$63+0x00000007c0102208.m(LMetafactoryArgValidationTest$C;)Ljava/lang/String; @1: invokespecial
        Reason:
          Type 'MetafactoryArgValidationTest$C' (current frame, stack[0]) is not assignable to 'MetafactoryArgValidationTest$C$$Lambda$63+0x00000007c0102208'
        Current Frame:
          bci: @1
          flags: { }
          locals: { 'MetafactoryArgValidationTest$C$$Lambda$63+0x00000007c0102208', 'MetafactoryArgValidationTest$C' }
          stack: { 'MetafactoryArgValidationTest$C' }
        Bytecode:
          0000000: 2bb7 0010 b0

      at java.base/java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:417)
      at java.base/java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass(InnerClassLambdaMetafactory.java:305)
      at java.base/java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:218)
      at java.base/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:328)
      at MetafactoryArgValidationTest.mfSucceed(MetafactoryArgValidationTest.java:240)
      ... 8 more

      In practice, this does not arise from Java method references because javac always generates a bridge for a 'super::foo' method reference.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dlsmith Dan Smith
              Reporter:
              dlsmith Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: