On Wed, 3 Jun 2026 13:29:39 GMT, Viktor Klang <[email protected]> wrote:
>> Per Minborg has updated the pull request with a new target base due to a
>> merge or a rebase. The incremental webrev excludes the unrelated changes
>> brought in by the merge/rebase. The pull request contains four additional
>> commits since the last revision:
>>
>> - Merge branch 'master' into rfe-clarify-lc-collections
>> - Fix typo
>> - Clarify equals throw conditions
>> - Remove the word 'may' from Object methods
>
> src/java.base/share/classes/java/util/List.java line 1248:
>
>> 1246: * {@linkplain NoSuchElementException}, and the {@linkplain
>> List#equals(Object)}
>> 1247: * <em>may</em> throw {@linkplain NoSuchElementException}
>> depending on which
>> 1248: * elements (if any) are compared.
>
>> depending on which
> * elements (if any) are compared.
>
> This reads a bit strange for me—in what way does it change depending of which
> elements are compared?
So, if `equals()` is invoked with an `obj="a"` then `obj` is not an instance of
`List` and no elements are compared, and the method would not throw.
If we have a list with `N` elements for which an element failed computation,
and we compare against another (RandomAccess) list with `N1 != N` elements,
then no elements are compared, and the method would not throw.
If we have a List with `N` elements and the last element's computation failed
`[N-1]` and we compare against another `List` with `N1 == N` elements but where
any of the non-last elements differ, then the method would not throw.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/31274#discussion_r3349265992