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

generics: incorrect unchecked exception

    XMLWordPrintable

Details

    • rc
    • generic
    • solaris_7

    Description

      $ cat -n T.java
           1 // from the library
           2 class Comparator<T> {}
           3
           4 // from the library
           5 class TreeSet<T> {
           6 public TreeSet(Comparator<T> c) {}
           7 }
           8
           9 // in non-generic user code
          10 public class T {
          11 void f() {
          12 Comparator HASH_COMPARATOR = null;
          13 TreeSet set = new TreeSet(HASH_COMPARATOR);
          14 }
          15 }
      $ newjavac -warnunchecked T.java
      T.java:13: warning: unchecked call to TreeSet(Comparator<T>) as a member of the raw type TreeSet
              TreeSet set = new TreeSet(HASH_COMPARATOR);
                            ^
      1 warning
      $

      Attachments

        Activity

          People

            gbrachasunw Gilad Bracha (Inactive)
            gafter Neal Gafter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: