Re[2]: Checking instanceof in DualPivotQuicksort

Vladimir Yaroslavskiy vlv.spb.ru at mail.ru
Fri Nov 1 19:23:55 UTC 2019


Hi Brent,

I agree with you, IllegalArgumentExceptions will help to catch invalid cases
if we change the source in future. Please go ahead with integration.

Thank you,
Vladimir


>25  Oct 2019, 8:28 +03:00 от Brent Christian <brent.christian at oracle.com>:
>
>Hi, Vladimir
>
>I'd prefer to keep the code as is.  Perhaps the exception could help 
>some other future maintainer to pinpoint a problem with a potential change.
>
>-Brent
>
>On 10/24/19 5:11 AM, Vladimir Yaroslavskiy wrote:
>> Hi Brent,
>> 
>> Looking at coverage of DualPivotQuicksort class, I found that
>> cases of unexpected type of given array are not invoked at all
>> (mentioned in my previous email).
>> 
>> I think that these "else" can be removed, because method
>> compute() of private classes are invoked from DualPivotQuicksort
>> class only and we can guarantee valid array types (int[], .. , double[]).
>> 
>> If you agree, could you please, remove such cases?
>> 
>> Replace lines 4147-4148:
>> 
>> throw new IllegalArgumentException(
>>      "Unknown type of array: " + a.getClass().getName());
>> 
>> by return null;
>> 
>> remove lines 4099-4101:
>> 
>> } else {
>>      throw new IllegalArgumentException(
>>          "Unknown type of array: " + dst.getClass().getName());
>> 
>> and remove lines 4030-4033:
>> 
>> } else {
>>      throw new IllegalArgumentException(
>>          "Unknown type of array: " + a.getClass().getName());
>> 
>> -----
>> 
>> And doe the same for Sorting class: remove 12 cases
>> fail("Unknown type of array: " + ....
>> 
>> Thank you,
>> Vladimir
>> 


-- 
Vladimir Yaroslavskiy


More information about the core-libs-dev mailing list