JDK-8213703 : LambdaConversionException: Invalid receiver type not a subtype of implementation type interface
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 11.0.1
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-11-09
  • Updated: 2021-07-07
  • Resolved: 2018-12-05
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 11 JDK 12
11.0.9-oracleFixed 12 b23Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
The stack trace is similar to JDK-8023558, JDK-8191655, and JDK-8207320, but the other issues are fixed and this one reproduces with 11.0.1+13.

```
import java.util.Arrays;
import java.util.List;

abstract class A {}

interface B {
  boolean g();
}

class C extends A implements B {
  public boolean g() {
    return true;
  }
}

class D<R extends A & B> {
  public long f(List<? extends R> xs) {
    return xs.stream().filter(B::g).count();
  }

  public static void main(String[] args) {
    long count = new D<C>().f(Arrays.asList(new C()));
    System.err.println(count);
  }
}
```

```
$ javac -fullversion
javac full version "11.0.1+13"
$ java D
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:307)
	at java.base/java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:258)
	at java.base/java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:248)
	at D.f(T.java:18)
	at D.main(T.java:22)
Caused by: java.lang.invoke.LambdaConversionException: Invalid receiver type class A; not a subtype of implementation type interface B
	at java.base/java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:254)
	at java.base/java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:328)
	at java.base/java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:127)
	... 5 more
```
Comments
jdk11 backport request I would like to have the patch in OpenJDK11 as well (for better parity with 11.0.9_oracle). The patch applies cleanly.
17-07-2020