Compilation failure on JDK 8 involving inferred generic type

Vicente-Arturo Romero-Zaldivar vicente.romero at oracle.com
Fri Jan 10 05:08:03 PST 2014


Hi Gunnar,

Yes this is the right list, sorry for the late response. I will look at it.

Thanks,
Vicente

On 10/01/14 12:42, Gunnar Morling wrote:
> Hi,
>
> Does anyone have an idea whether this is a regression or an 
> intentional change? My apologies, if this is not the right place to 
> ask this question (I'd be happy then about a pointer where to post 
> it instead).
>
> Many thanks,
>
> --Gunnar
>
>
>
> 2014/1/3 Gunnar Morling <gunnar at hibernate.org 
> <mailto:gunnar at hibernate.org>>
>
>     Hi,
>
>     I'm investigating a compilation error which I'm seeing when
>     compiling the Bean Validation TCK using JDK 8 (build 121). The
>     following example shows the issue:
>
>         public class GenericsTest {
>             public class Input<O extends Output<O>> {}
>             public class Output<O extends Output<O>> {}
>             public class OutputContainer<O extends Output<O>> {}
>             public <O extends Output<O>, I extends Input<O>>
>     OutputContainer<O> process(
>                     Class<I> inputType) {
>                 return null;
>             }
>             public void testProcess() {
>                 Class<? extends Input> inputType = null;
>
>                 //next line compiles with source level 1.7 but fails
>     with source level 1.8
>                 OutputContainer<?> outputContainer = process( inputType );
>             }
>         }
>
>     This code used to compile with JDK 7 and it also does with JDK 8,
>     when using 1.7 as source level. But it fails with source level
>     1.8, saying:
>
>         "incompatible types: inferred type does not conform to upper
>     bound(s)"
>
>     I can make the code compile when declaring the outputContainer
>     variable of the raw type OutputContainer instead of declaring it
>     with the wildcard parameter.
>
>     Is this an intentional change in JDK 8 or is it some kind of
>     regression? If it is intentional, maybe the error message should
>     be a bit more descriptive, mentioning the concerned inferred type
>     and the bounds?
>
>     Many thanks,
>
>     --Gunnar
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20140110/f06795fe/attachment.html 


More information about the compiler-dev mailing list