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

(coll) The set returned by TreeMap.keySet should implement SortedSet

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 1.4.2
    • core-libs

      Name: rmT116609 Date: 08/26/2003


      A DESCRIPTION OF THE PROBLEM :
      I think that the Set returned by TreeMap.keySet should implement SortedSet, because it's actually a sorted Set.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      C:\java\src>java Test
      Exception in thread "main" java.lang.ClassCastException: java.util.TreeMap$1
              at Test.main(Test.java:7)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.*;

      public class Test {
          public static void main(String[] args) {
              TreeMap map=new TreeMap();
              map.put("Hello","World");
              SortedSet keySet=(SortedSet)map.keySet();
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      Directly use the methods of TreeMap.
      (Incident Review ID: 164293)
      ======================================================================

            martin Martin Buchholz
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: