On Sat, 1 Apr 2023 23:28:51 GMT, Nir Lisker <[email protected]> wrote:
>> Michael Strauß has updated the pull request incrementally with one
>> additional commit since the last revision:
>>
>> addressed review comments, added tests
>
> modules/javafx.base/src/main/java/com/sun/javafx/collections/ObservableSequentialListWrapper.java
> line 178:
>
>> 176: @Override
>> 177: public boolean addAll(int index, Collection<? extends E> c) {
>> 178: if (index < 0 || index > size()) {
>
> If you want, there are methods in `Objects` that do range checks, like
> `Objects.checkIndex`.
>
> Same for the other files.
In order to use `Objects.checkIndex` here, I would have to call it like this:
`Objects.checkIndex(index, size() + 1)`.
`size() + 1` is necessary because it is valid to call this method with an
`index` equal to the size of the list.
However, the exception message that would be produced for an out-of-bounds
index would be incorrect, for example when adding elements at index 20 to a
list that already contains 10 elements: "Index 20 out of bounds for length 11".
Obviously, a list of 10 elements doesn't have a length of 11.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/751#discussion_r1155392501