Change in javac generics type inference

Martin Buchholz martinrb at
Thu Feb 5 18:38:46 PST 2009

Hi javac maintainers,

We have a program that started to fail to compile as of jdk7-b05
(openjdk6 is naturally also affected)

I'm not an expert on generics type inference,
but the code seems reasonable, and used to compile,

 $ cat; for java in jdk1.7.0-b04 jdk1.7.0-b05; do echo ---
$java ---- ; /home/build/static/projects_norep/java/sun-jdk/linux-i586/$java/bin/javac; done
public class Bug {

  public static <K extends Key<K>, E extends Entity<E, K>> void get(E entity) {}

  public interface Entity<E extends Entity<E, K>, K extends Key<K>> {}

  public interface Key<K extends Key<K>> {}

  public static class EntityImpl implements Entity<EntityImpl, KeyImpl> {}

  public static class KeyImpl implements Key<KeyImpl> {}

  public static void main(String[] args) {
    EntityImpl e = new EntityImpl();
--- jdk1.7.0-b04 ----
--- jdk1.7.0-b05 ---- incompatible types; inferred type argument(s)
java.lang.Object do not conform to bounds of type variable(s) K
found   : <K>void
required: void
1 error

More information about the compiler-dev mailing list