On Mon, 23 Jan 2023 07:20:39 GMT, Tingjun Yuan <d...@openjdk.org> wrote:

>> Document `java.util.Arrays.asList` that the list will throw an 
>> `ArrayStoreException` when attempting to set an element with a wrong type.
>
> Tingjun Yuan has updated the pull request incrementally with two additional 
> commits since the last revision:
> 
>  - Restore List.java
>  - Fix whitespace error

Changes requested by dholmes (Reviewer).

src/java.base/share/classes/java/util/Arrays.java line 4116:

> 4114:      *
> 4115:      * @implNote
> 4116:      * Modification methods of the returned list (such as {@link 
> List#set} and

(This got buried in a commit specific message that got lost with the updates.)

My personal preference would be to call out explicitly what happens here:

@implNote
The  {@link List} implementation returned by this method does not conform to 
the 
specification for List.replaceAll and List.set, in that in the event of 
encountering an
element of an unsuitable type, ArrayStoreException will be thrown instead of 
ClassCastException.

(with suitable formatting of course). I don't think an example is necessary.

-------------

PR: https://git.openjdk.org/jdk/pull/12135

Reply via email to