Andrew Haley wrote:
Marco Trudel writes:
> Hey guys
>
> java.util.Arrays.binarySearch(Object[] a, Object key, Comparator c)
> exchanges a[i] and key, this can lead to ClassCastExceptions as shown in
> ComparatorTest.java. Arrays.patch fixes it.
>
>
> Changelog suggestion:
>
> 2006-12-13 Marco Trudel <[EMAIL PROTECTED]>
>
> * classpath/java/util/Arrays.java (binarySearch(Object[] a, Object key,
> Comparator c)):
> Fix swapped objects inCollections.compare(...) call.
>
>
> Comments?
I guess I don't get it. Arrays.binarySearch() is defined to be
searching for a key in an array. The comparator has to be able to
compare keys and values. How is this not a bug in the test case?
The key might be a different object that the values. The comparator will
then be responsible to see if they're equal. Thus the order is important...
Marco