Checking instanceof in DualPivotQuicksort

Brent Christian brent.christian at oracle.com
Fri Oct 25 05:28:53 UTC 2019


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
> 


More information about the core-libs-dev mailing list