JDK-8268192 : LambdaMetafactory with invokespecial causes VerificationError
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: 17
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-06-03
  • Updated: 2021-06-11
  • Resolved: 2021-06-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b26Fixed
Related Reports
Duplicate :  
Relates :  
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.

Comments
Changeset: 58ba48b7 Author: Dan Smith <dlsmith@openjdk.org> Date: 2021-06-09 23:57:41 +0000 URL: https://git.openjdk.java.net/jdk/commit/58ba48b7b88eff359683aa3271c48b18f1973282
09-06-2021

Was observed a year ago, here: JDK-8246790
08-06-2021