javac rejects valid java 7 code

Anna Kozlova anna.kozlova at
Mon Nov 18 07:31:30 PST 2013



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?




More information about the lambda-dev mailing list