[cp-patches] java.util.Arrays fix

David Daney ddaney at avtrex.com
Wed Dec 13 20:40:39 UTC 2006


Casey Marshall wrote:
> On Dec 13, 2006, at 12:21 PM, David Daney wrote:
> 
>> Casey Marshall wrote:
>>
>>> On Dec 13, 2006, at 12:56 AM, Marco Trudel wrote:
>>>
>>>> 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.
>>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30061
>>
>>
>> This exact problem bit me once.  I developed code on the RI that  
>> inadvertently had a comparator that depended on the order of the  
>> arguments.
>>
>> I freely admit that my code was incorrect,  but it did take me a  
>> while to figure out what was happening.
>>
>> I feel that if there is no performance penalty, then we should  follow 
>> the behavior of the RI.
>>
> 
> I agree, since we have a patch. As long as it tests out OK, I'm not  
> opposed to including it.
> 
> In general I really urge against going out of our way to support  
> behavior like this.

I changed my mind!  As a matter of principle, since I had to fix my 
code, everyone should have to suffer in the same manner, as their 
penalty for disobeying the mandates of the specification! :)

David Daney



More information about the Classpath-patches mailing list