JDK-8028813 : Lambda Spec: Take multiple upper bounds into account in incorporation
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-11-21
  • Updated: 2014-03-14
  • Resolved: 2013-12-18
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 8
8Fixed
Related Reports
Relates :  
Relates :  
Description
Consider two upper bounds, at least one of which mentions an inference variable:
a <: Foo<b>
a <: Bar<String>

If these upper bounds share a parameterized type, we can infer additional constraints from the type arguments (e.g., maybe b = String).

Here's an example (notably, this compiles in 7, due to a quirk in javac's implementation):

interface Task<E extends Exception> {}
class Comparator<T> {}
class CustomException extends Exception {}

class TaskQueue<E extends Exception, T extends Task<E>> {}

abstract class Test {
 abstract <E extends Exception, T extends Task<E>>
     TaskQueue<E, T> create(Comparator<? super T> comparator);

 void f(Comparator<Task<CustomException>> comp) {
   TaskQueue<CustomException, Task<CustomException>> queue = create(comp);
 }
}

Reported on lambda-dev: http://mail.openjdk.java.net/pipermail/lambda-dev/2013-November/011442.html
Comments
Added the following incorporation rule to 18.3 (after the list of general rules, but before the discussion of capture bounds): ***If two bounds have the form �� <: S and �� <: T, and if for some generic class or interface, G, there exists a supertype 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.*** This allows us to avoid checking for inconsistent upper bounds at resolution time (18.4): If the resulting type variables Z1, ..., Zn do not have well-formed bounds (that is, ***a lower bound is not a subtype of an upper bound***), then resolution fails.
18-12-2013