-
Enhancement
-
Resolution: Won't Fix
-
P5
-
None
-
1.4.2
-
x86
-
windows_2000
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)
======================================================================
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)
======================================================================
- relates to
-
JDK-4155650 (coll) Sorted Collection Classes with bidirectional navigation
- Resolved
-
JDK-6415641 (coll) Getting NavigableMap/NavigableSet right
- Closed