JDK-8154792 : Failure to detect malformed parameterized type
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7u51,8u60,9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2016-04-20
  • Updated: 2017-12-07
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 program compiles without error.  An error is expected.

public class Test {
    interface I<T extends Class<S>, S> {}
    
    <T extends Class<?>> void test() {
        I<T,?> val;
    }
}

Specifically, the type 'I<T,?>' is malformed, and so should produce an error (JLS 4.5).

"When subjected to capture conversion"
--> 'I<T,CAP>'
"each type argument Xi is a subtype of" its bound
--> T <: Class<CAP>

Because T has upper bound Class<?>, it is not a subtype of Class<CAP> -- in fact, there exists no type Foo such that T <: Class<Foo>.

(Some aspects of type variables with wildcard-parameterized bounds are under-specified, but in this case, the definition of subtyping is clear.)

This appears to be longstanding behavior, probably since Java SE 5.
Comments
JDK-8054937 raises a similar concern, but in that case the problem is that the constraint can only be satisfied by some instantiations of 'CAP'. Here, there are no instantiations of 'CAP' that would satisfy the subtyping constraint.
20-04-2016

This issue came up in a discussion with Anna Kozlova.
20-04-2016