JDK-8051818 : Subtyping failure involving capture
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6u65,7u51,8
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2014-07-23
  • Updated: 2015-12-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 :  
Description
The following should compile but does not.  Appeared in the paper "Taming Wildcards in Java's Type System," Ross Tate et al., PLDI 2011.

import java.util.*;

public class TateFigure5 {

class C<P extends Number> extends ArrayList<P> {}
List<? extends List<? extends Number>> cast(List<C<?>> list)
{return list;}

}

The subtyping derivation is straightforward:
List<C<?>> <: List<? extends List<? extends Number>>
C<?> <: List<? extends Number>
List<CAP extends Number> <: List<? extends Number>
CAP extends Number <: Number
true

Interestingly, if C is an interface that extends List rather than a class that extends ArrayList, compilation succeeds.

This is longstanding behavior, probably due to the way javac handles wildcards in subtyping.  Not a regression.