javac rejects valid java 7 code

Vicente-Arturo Romero-Zaldivar vicente.romero at oracle.com
Mon Nov 18 12:07:43 PST 2013


Hi Anna,

This issue should be investigated, I have created bug entry: 
https://bugs.openjdk.java.net/browse/JDK-8028547, to track this,

Thanks,
Vicente


On 18/11/13 15:31, Anna Kozlova wrote:
> Hi,
>
>   
>
> This code compiles with java 1.7 (also 1.6) but fails to compile with 1.8
> (b. 115)
>
>   
>
> abstract class A2<T>{
>
>      abstract <S> S foo(S x, S y);
>
>      abstract <S1> void baz(A2<S1> a)
>
>   
>
>      void bar(A2<Integer> y, A2<Long> x){
>
>           baz(foo(x, y));
>
>      }
>
> }
>
>   
>
> java: method baz in class A2<T> cannot be applied to given types;
>
>    required: A2<S1>
>
>    found: A2<capture#1 of ? extends java.lang.Number&java.lang.Comparable<?
> extends java.lang.Number&java.lang.Comparable<?>>>
>
>    reason: inferred type does not conform to equality constraint(s)
>
>      inferred: java.lang.Long
>
>      equality constraints(s): java.lang.Long,java.lang.Integer
>
>   
>
> Are these equality constraint really for S1? How does javac get them
> independently from whom they belong?
>
>   
>
> Thanks,
>
> Anna
>
>



More information about the lambda-dev mailing list