jdk/src/share/classes/java/util/TreeSet.java
changeset 12448 b95438b17098
parent 10419 12c063b39232
child 14342 8435a30053c1
--- a/jdk/src/share/classes/java/util/TreeSet.java	Tue Apr 17 11:59:12 2012 -0700
+++ b/jdk/src/share/classes/java/util/TreeSet.java	Tue Apr 17 12:21:56 2012 -0700
@@ -302,7 +302,7 @@
             m instanceof TreeMap) {
             SortedSet<? extends E> set = (SortedSet<? extends E>) c;
             TreeMap<E,Object> map = (TreeMap<E, Object>) m;
-            Comparator<? super E> cc = (Comparator<? super E>) set.comparator();
+            Comparator<?> cc = set.comparator();
             Comparator<? super E> mc = map.comparator();
             if (cc==mc || (cc != null && cc.equals(mc))) {
                 map.addAllForTreeSet(set, PRESENT);
@@ -469,8 +469,9 @@
      *
      * @return a shallow copy of this set
      */
+    @SuppressWarnings("unchecked")
     public Object clone() {
-        TreeSet<E> clone = null;
+        TreeSet<E> clone;
         try {
             clone = (TreeSet<E>) super.clone();
         } catch (CloneNotSupportedException e) {
@@ -519,14 +520,11 @@
         s.defaultReadObject();
 
         // Read in Comparator
-        Comparator<? super E> c = (Comparator<? super E>) s.readObject();
+        @SuppressWarnings("unchecked")
+            Comparator<? super E> c = (Comparator<? super E>) s.readObject();
 
         // Create backing TreeMap
-        TreeMap<E,Object> tm;
-        if (c==null)
-            tm = new TreeMap<>();
-        else
-            tm = new TreeMap<>(c);
+        TreeMap<E,Object> tm = new TreeMap<>(c);
         m = tm;
 
         // Read in size