RFR 8141409 Arrays.equals accepting a Comparator

Roger Riggs Roger.Riggs at Oracle.com
Thu Nov 12 16:42:28 UTC 2015


Hi Paul,

- A minor point but in the argument names, its a bit inconsistent 
between using 'b' and 'a2'.
I would have use 'a', and 'b' to be more consistent.  (and yes the 
current methods show the same inconsistency)

- The @return(s) should have an 'otherwise {@code false};  otherwise 
maybe it is allowed to return true.

- In the implementation, I generally prefer the form of 
Objects.requireNonNull(o, "name") so the exception
identifies the offending argument.

- I thought the coding style has spaces around operators (like ==).

- The non-range checked version of equals should have the same behavior as:
    equals(a, 0, a.length, a2, 0, a2.length).

The range checked version should include the sentence:

"Also, two array references are  considered equal if both are {@code null}."

- The implementation will need to check for nulls before the rangeChecks.

Regards, Roger





On 11/12/2015 5:36 AM, Paul Sandoz wrote:
> Hi,
>
> I have made a retreat on this just to add the two missing equals methods:
>
>    http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8141409-Arrays-equals-comparator/webrev/ <http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8141409-Arrays-equals-comparator/webrev/>
>
> I propose to revisit the overall null-handling semantics, especially for Comparable[] accepting methods, at a later date.
>
> Paul.
>
>> On 4 Nov 2015, at 15:32, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
>>
>> Hi,
>>
>> Please review:
>>
>>   http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8141409-Arrays-equals-comparator/webrev/ <http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8141409-Arrays-equals-comparator/webrev/>
>>   https://bugs.openjdk.java.net/browse/JDK-8141409 <https://bugs.openjdk.java.net/browse/JDK-8141409>
>>
>> This builds on (the already reviewed):
>>
>>   https://bugs.openjdk.java.net/browse/JDK-8033148 <https://bugs.openjdk.java.net/browse/JDK-8033148>
>>   http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8033148-Arrays-lexico-compare/webrev/ <http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8033148-Arrays-lexico-compare/webrev/>
>>
>> and adds yet more methods to Arrays, only two this time though, to fill out the missing gaps related to array equality with a comparator.
>>
>> In addition i added an Objects.compare method, which simplifies the implementations of some object-bearing methods.
>>
>> Both additions simplify the specification some object-bearing methods.
>>
>> Paul.




More information about the core-libs-dev mailing list