On Tue, 4 Nov 2025 20:38:35 GMT, jengebr <[email protected]> wrote:

>> That variant is incorrect since `size <= a.length`, potentially adding a 
>> surprising tail of `null` elements to the list.
>
> Thank you both!  @cl4es splitting it out had zero performance impact (per the 
> benchmark).  As you said, it's a bit subjective... how strongly do you feel?  
> Other opinions are welcome too.

I would think that you need to check `src.modCount` has same value at start and 
end of the method.


final int expectedSrcModCount = src.modCount;
//access src internals....
checkForComodification(expectedSrcModCount)


Looks like ArrayList::toArray is not doing this check either.  So perhaps it is 
not needed.  I would have thought mod check would have been needed in toArray 
to mimic iterator behavior.  Therefore needed in addAll.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28116#discussion_r2492622937

Reply via email to