JDK-8037474 : Failure to detect conflicting upper bounds in inference
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Cannot Reproduce
  • Submitted: 2014-03-14
  • Updated: 2017-05-12
  • Resolved: 2017-05-12
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.
Other
tbd_majorResolved
Related Reports
Relates :  
Description
Test:

---
import java.util.List;

public class GLBConflict {

    interface I<S> {}
    interface J<S> extends I<S> {}
    interface J2<S> extends I<S> {}
    interface K extends I<String> {}

    <T> T upper2(List<? super T> l1, List<? super T> l2) { return null; }

    void test(List<I<String>> i, List<J<Integer>> j, List<J2<String>> j2, List<K> k) {
        upper2(i, j); // expected: error; actual: error
        upper2(j, j2); // expected: error; actual: ok
        upper2(j, k); // expected: error; actual: ok
    }

}
---

All three invocations of 'upper2' should fail, due to this clause (JLS 8 18.3):

"If two bounds have the form �� <: S and �� <: T, and if for some generic class or interface, G, there exists a supertype (4.10) of S of the form G<S1, ..., Sn> and a supertype of T of the form G<T1, ..., Tn>, then for all i, 1 ��� i ��� n, if Si and Ti are types (not wildcards), the constraint ���Si = Ti��� is implied."

Under '-source 7' and previous, there is not a clear specification for an error, but all three invocations otherwise produce a malformed intersection, which javac makes some effort to prevent.  If the first one is an error (javac claims it is), the other two should be errors, too.
Comments
already fixed in 9
12-05-2017