classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Collections.binarySearch and poorly written comparators


From: Jim Murphy
Subject: Collections.binarySearch and poorly written comparators
Date: Tue, 20 Dec 2005 17:39:43 -0500

Hi all,

We're using CLASSPATH together with our code and a 3rd party library.  The
library contains some poorly written comparators and uses of
Collections.binarySearch.  I say poorly written because in the comparator
implementation there is assumptions about the object types and that
assumption is causing me grief by way of a ClassCastException.

>From the comparator interface:

int compare(Object o1, Object o2);

The bad comparator implementation assumes that o1 is a Foo and o2 is a Bar.
This "works" when running on the Sum JRE implementation of
Ccollections.binarySearch but fails with the CLASSPATH's implementation
because the types are transposed.  

I will have a tough time changing the 3rd party library so I feel a little
stuck.  Any suggestions?  

If a goal of CLASSPATH is to be broadly useful does being "bug for bug"
compatible matter to you guys?  Would you consider this a bug?



Jim Murphy





reply via email to

[Prev in Thread] Current Thread [Next in Thread]