Fwd: Unable to compile code using generics under 8u20 but builds under 8u05

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Oct 14 09:44:14 UTC 2014


Hi,
we know about this regression - this problem has been exposed by the 
following (correct) fix:

https://bugs.openjdk.java.net/browse/JDK-8044546

which uncovered an underlying unsoundness during wildcards containment 
test. We made several attempts at fixing the issue, but in the end we 
deemed the full fix too risky for 8. Vicente has worked around the 
problem in 8u40:

https://bugs.openjdk.java.net/browse/JDK-8051402

I can confirm that the code in the example compiles fine with the 8u40 
compiler.

Thanks
Maurizio

On 14/10/14 01:46, Jonathan Gibbons wrote:
>
>
>
> -------- Forwarded Message --------
> Subject: 	Unable to compile code using generics under 8u20 but builds 
> under 8u05
> Date: 	Mon, 13 Oct 2014 13:47:31 +0100
> From: 	Will May <will.j.may at gmail.com>
> To: 	jdk8u-dev at openjdk.java.net
>
>
>
> Hi all,
>
> I've got a piece of code which will compile fine on JDK 8u05 but fails to
> compile [1] on JDK 8u20; a minimal test case is at the bottom of this email.
>
> I know that there were changes around generic wildcards in 8u20 but does
> anyone know if 8u05 is bugged and it has been fixed or if 8u20 is now
> bugged?
>
> For reference, the two bugs that I found were fixed around generic
> wildcards were 8042338 [2] and 8042803 [3].
>
> Cheers,
>
> Will.
>
> 1 The error message is "incompatible types:
> java.util.function.Consumer<capture#1 of ?> cannot be converted to
> java.util.function.Consumer<? super capture#1 of ?>"
> 2https://bugs.openjdk.java.net/browse/JDK-8042338
> 3https://bugs.openjdk.java.net/browse/JDK-8042803
>
> import java.util.List;
> import java.util.function.Consumer;
>
> public class Temp {
>
>      public void doWithList(final List<?> list) {
>          list.stream().forEach(consumer(System.out::println));
>      }
>
>      @FunctionalInterface
>      public static interface ExceptionThrowingConsumer<T> {
>          void accept(T input) throws Exception;
>      }
>
>      public static <T> Consumer<T> consumer(ExceptionThrowingConsumer<T>
> consumer) {
>          return i -> {
>              try {
>                  consumer.accept(i);
>              } catch (Exception e) {
>                  throw new RuntimeException(e);
>              }
>          };
>      }
>
> }
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20141014/94aaa12b/attachment.html>


More information about the compiler-dev mailing list