# HG changeset patch # User Artem Tikhomirov # Date 1372964973 -7200 # Node ID d10399f80f4ed3aa9838f0a9ebffb277eb3fc49b # Parent 6334b026710381f62e2ab64c97d868542f4e92af javac complained about casts, while eclipse compiler is fine diff -r 6334b0267103 -r d10399f80f4e src/org/tmatesoft/hg/internal/ArrayHelper.java --- a/src/org/tmatesoft/hg/internal/ArrayHelper.java Thu Jul 04 20:27:45 2013 +0200 +++ b/src/org/tmatesoft/hg/internal/ArrayHelper.java Thu Jul 04 21:09:33 2013 +0200 @@ -110,8 +110,7 @@ * Slightly modified version of Arrays.sort1(int[], int, int) quicksort alg (just to deal with Object[]) */ private void sort1(int off, int len) { - @SuppressWarnings("unchecked") - Comparable[] x = (Comparable[]) sorted; + Comparable[] x = comparableSorted(); // Insertion sort on smallest arrays if (len < 7) { for (int i=off; i[] x = (Comparable[]) sorted; + Comparable[] x = comparableSorted(); return (x[a].compareTo(x[b]) < 0 ? (x[b].compareTo(x[c]) < 0 ? b : x[a].compareTo(x[c]) < 0 ? c : a) : (x[b].compareTo(x[c]) > 0 ? b : x[a].compareTo(x[c]) > 0 ? c : a)); } + + private Comparable[] comparableSorted() { + // Comparable[] x = (Comparable[]) sorted + // eclipse compiler is ok with the line above, while javac doesn't understand it: + // inconvertible types found : T[] required: java.lang.Comparable[] + // so need to add another step + Comparable[] oo = sorted; + @SuppressWarnings("unchecked") + Comparable[] x = (Comparable[]) oo; + return x; + } /** * Swaps x[a] with x[b].