javac rejects valid java 7 code

Anna Kozlova anna.kozlova at jetbrains.com
Mon Nov 18 12:12:09 PST 2013


Vicente,

Could you please take into account also two variations (difference in bounds
of the second method type parameters only):

abstract class A<T>{
    abstract <S> S foo(S x, S y);
    <S extends Number & Comparable<? extends Number>> void baz(A<S> a){}

    void bar(A<Long> x, A<Integer> y){
        baz(foo(x, y));
    }
}

abstract class A1<T>{
    abstract <S> S foo(S x, S y);
    <T extends Number & Comparable<?>, S extends Number & Comparable<?
extends T>> void baz(A1<S> a){}

    void bar(A1<Long> x, A1<Integer> y){
        baz(foo(x, y));
    }
}

Thanks, 
Anna

-----Original Message-----
From: Vicente-Arturo Romero-Zaldivar [mailto:vicente.romero at oracle.com] 
Sent: Monday, November 18, 2013 9:08 PM
To: Anna Kozlova; lambda-dev at openjdk.java.net
Subject: Re: javac rejects valid java 7 code

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
>
>


!DSPAM:35,528a73a262931173217933!




More information about the lambda-dev mailing list