--- a/jdk/src/share/classes/java/util/TreeMap.java Thu Aug 08 23:40:46 2013 -0700
+++ b/jdk/src/share/classes/java/util/TreeMap.java Fri Aug 09 11:44:38 2013 +0200
@@ -2944,16 +2944,11 @@
@Override
public Comparator<Map.Entry<K, V>> getComparator() {
- // Since SORTED is reported and Map.Entry elements are not comparable
- // then a non-null comparator needs to be returned
+ // Adapt or create a key-based comparator
if (tree.comparator != null) {
- // Adapt the existing non-null comparator to compare entries
- // by key
return Map.Entry.comparingByKey(tree.comparator);
}
else {
- // Return a comparator of entries by key, with K assumed to be
- // of Comparable
return (Comparator<Map.Entry<K, V>> & Serializable) (e1, e2) -> {
@SuppressWarnings("unchecked")
Comparable<? super K> k1 = (Comparable<? super K>) e1.getKey();