Array equality, comparison and mismatch
Paul Sandoz
paul.sandoz at oracle.com
Tue Oct 6 08:50:57 UTC 2015
> On 5 Oct 2015, at 17:35, Chris Hegarty <chris.hegarty at oracle.com> wrote:
>
> Paul,
>
> On 22/09/15 17:30, Paul Sandoz wrote:
>> Hi,
>>
>> Please review the following which adds methods to Arrays for performing equality, comparison and mismatch:
>>
>> 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/specdiff/overview-summary.html
>
> This looks very good.
>
> I know that there has been some discussion already about the behavior when passed null, but it seems a little unfortunate that the range accepting 'equals' methods don't behave in a similar manner to that of the non-range 'equals' methods. But I do accept that it makes little sense, where would the from/to indices come from. So I think NPE makes sense for these.
>
Note that this consistent with other range accepting methods, such as on Arrays or Spliterators (which also usually throw null on the non-range methods too, i wish we could be consistent in that aspect).
> It was not immediately obvious to me that the common prefix can be 0. Should this be called out specifically?
>
When reading the documentation of compare or mismatch or both?
> Minor typo(s):
>
> "...the length of the smaller array and it follows THAT the
> index is only valid ..."
>
> "If one array is a proper prefix of the other, over the specified
> ranges, then the returned relative index is the length of the
> smaller range and it follows THAT the relative index is only valid
> for the array with the larger range.”
>
Fixed.
Thanks,
Paul.
More information about the core-libs-dev
mailing list