src/share/classes/java/util/ComparableTimSort.java

Print this page
rev 4788 : Fix bunch of generics warnings

@@ -112,11 +112,10 @@
     private ComparableTimSort(Object[] a) {
         this.a = a;
 
         // Allocate temp storage (which may be increased later if necessary)
         int len = a.length;
-        @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
         Object[] newArray = new Object[len < 2 * INITIAL_TMP_STORAGE_LENGTH ?
                                        len >>> 1 : INITIAL_TMP_STORAGE_LENGTH];
         tmp = newArray;
 
         /*

@@ -207,18 +206,17 @@
      * @param lo the index of the first element in the range to be sorted
      * @param hi the index after the last element in the range to be sorted
      * @param start the index of the first element in the range that is
      *        not already known to be sorted ({@code lo <= start <= hi})
      */
-    @SuppressWarnings("fallthrough")
+    @SuppressWarnings({ "fallthrough", "rawtypes", "unchecked" })
     private static void binarySort(Object[] a, int lo, int hi, int start) {
         assert lo <= start && start <= hi;
         if (start == lo)
             start++;
         for ( ; start < hi; start++) {
-            @SuppressWarnings("unchecked")
-            Comparable<Object> pivot = (Comparable) a[start];
+            Comparable pivot = (Comparable) a[start];
 
             // Set left (and right) to the index where a[start] (pivot) belongs
             int left = lo;
             int right = start;
             assert left <= right;

@@ -277,11 +275,11 @@
      * @param hi index after the last element that may be contained in the run.
               It is required that {@code lo < hi}.
      * @return  the length of the run beginning at the specified position in
      *          the specified array
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private static int countRunAndMakeAscending(Object[] a, int lo, int hi) {
         assert lo < hi;
         int runHi = lo + 1;
         if (runHi == hi)
             return 1;

@@ -612,11 +610,11 @@
      * @param len1  length of first run to be merged (must be > 0)
      * @param base2 index of first element in second run to be merged
      *        (must be aBase + aLen)
      * @param len2  length of second run to be merged (must be > 0)
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private void mergeLo(int base1, int len1, int base2, int len2) {
         assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
 
         // Copy first run into temp array
         Object[] a = this.a; // For performance

@@ -729,11 +727,11 @@
      * @param len1  length of first run to be merged (must be > 0)
      * @param base2 index of first element in second run to be merged
      *        (must be aBase + aLen)
      * @param len2  length of second run to be merged (must be > 0)
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private void mergeHi(int base1, int len1, int base2, int len2) {
         assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
 
         // Copy second run into temp array
         Object[] a = this.a; // For performance

@@ -863,11 +861,10 @@
             if (newSize < 0) // Not bloody likely!
                 newSize = minCapacity;
             else
                 newSize = Math.min(newSize, a.length >>> 1);
 
-            @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
             Object[] newArray = new Object[newSize];
             tmp = newArray;
         }
         return tmp;
     }