JDK-8024484 : 8.4.2: Define when bounds are the same
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 5.0,7,8
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-09-09
  • Updated: 2016-08-11
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_majorUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
It is not clear whether the following two signatures are "the same" or not:

public static <T1 extends Cloneable & Iterable<String>> void foo(T1 x)
public static <T2 extends Iterable<String> & Cloneable> void foo(T2 x)

The condition that must be satisfied, from 8.4.2, is "the bounds of corresponding type variables are the same".

This could be interpreted as having the same (unordered) set of bounds, or as having the same (ordered) list of bounds.

javac prefers the set interpretation when determining overriding relationships, although it is internally inconsistent at times (see JDK-8013089, JDK-8013846).

In fact, javac seems take this even a step further, by determining whether the intersection types suggested by the two lists of bounds are structurally equivalent -- e.g., T extends Object & Runnable & Cloneable == T extends Runnable & Cloneable.

A risk of being to narrow in the definition of "the same" is that two declarations that "obviously" appear to be the same won't be related.  A risk of being too broad is that erasure is no longer consistent between signatures that are "the same" (as in JDK-8013089).
Comments
A fix for this bug should also update 18.2.4: inferring that two intersection types are "the same".
16-12-2013

To clarify the point about erasure, currently the erasure of an intersection is the first element of the "set", implying an ordering on the elements of the "set".
10-09-2013