Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6497707

Problem with underconstrained type variable and super bounded wildcards

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 6
    • tools
    • generic
    • generic

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

            Unassigned Unassigned
            ahe Peter Ahe
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: