generic compile problem

Alex Buckley alex.buckley at oracle.com
Tue Dec 11 12:25:55 PST 2012


In an assignment context, is a widening reference conversion possible 
from Class<test2> to Class<? extends test2<?>> ?

In turn, is Class<test2> a subtype of Class<? extends test2<?>> ?

In turn, is test2 contained by '? extends test2<?>' ?

The rules of JLS 4.5.1 do not support that containment, so no, there is 
no formal subtype relation.

Alex

On 12/11/2012 12:00 PM, Radim Kolar wrote:
> I need to know if javac is correct. Eclipse Juno compiles it. Program
>
> public class test2 <K> {
>
> public void test() {
>    Class <? extends test2 <?>> t = test2.class;
> }
> }
>
> C:\1>javac test2.java
> test2.java:4: error: incompatible types
>    Class <? extends test2 <?>> t = test2.class;
>                                         ^
>    required: Class<? extends test2<?>>
>    found:    Class<test2>
> 1 error
>
> discussion with remarks to JLS is at
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=396231



More information about the compiler-dev mailing list