JDK-6497707 : Problem with underconstrained type variable and super bounded wildcards
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 6
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-11-27
  • Updated: 2010-04-02
  • Resolved: 2009-03-13
Related Reports
Duplicate :  
Description
$ cat -n A.java
     1  import java.util.*;
     2  class Comparators {
     3    public static <C extends Comparable<? super C>> Comparator<C> naturalOrder() {
     4      return null;
     5    }
     6    public static Comparator<Integer> c() {
     7      return naturalOrder();
     8    }
     9  }
$ /usr/local/jdk6/bin/javac A.java
A.java:7: incompatible types; no instance(s) of type variable(s) C exist so that java.util.Comparator<C> conforms to java.util.Comparator<java.lang.Integer>
found   : <C>java.util.Comparator <C>
required: java.util.Comparator<java.lang.Integer>
    return naturalOrder();
                       ^
1 error
$