JDK-8205052 : No compilation error thrown when no valid parameterization exists for functional interface type
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 11
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-06-14
  • Updated: 2018-08-17
  • Resolved: 2018-06-19
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
11 b19Fixed
Related Reports
Relates :  
Description
Please refer to below code: 

class U1 {}
class U3 {}

class X1 extends U1 {}
class X3 extends U3 {}

@FunctionalInterface
interface SAM<P1 extends X1, P2 extends P1, P3 extends X3> {
    P3 m(P1 p1, P2 p2);
}

interface I<T> { }

@SuppressWarnings("unchecked")
class Tester {
    public X3 foo(X1 x1, Object x2) { return new X3(); }
    Object method(SAM<?, ?, ?> sam) {
        return sam.m(null, null);
    }
    Object run() {
        return method((SAM<?, ?, ?> & I<?>) this::foo);
    }
}

public class LmbdTest  {
    public static void main(String argv[]) {
    	new Tester().run();
    }
} 

In the above code, we have functional interface type parameter bounded to another type parameter. The method parameter has unbounded wildcard type arguments.

Earlier the code used to fail with correct error as below:

error: incompatible types: cannot infer functional interface descriptor for SAM<X1,Object,X3>
        return method((SAM<?, ?, ?> & I<?>) this::foo);

Now, there is no error thrown which is not as per expectation.

Sample reproducible test case file is attached.
Comments
Product tested: JDK 11b26 vs JCK 11b12 TestSuite: JCK-compiler OS: Linux x64 Tests Passed: lang/LMBD/lmbd076/lmbd07602m1w22/lmbd07602m1w22.html
17-08-2018

the regression was provoked by: JDK-8148354
19-06-2018