Andrew Haley wrote:
Marco Trudel writes:
 > 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...

OK, but where does it say that in the spec?

Sorry, I did not read the spec. This somehow seems logical to me.
Also this is a regression in classpath that was introduced with a refactoring of binarySearch(...) and a Sun JVM does it the logical way too. Even if it's considered unlogical, the swap wouldn't affect it then... So I guess this is safe to commit.

Marco

Reply via email to