RFR: 8371164: ArrayList.addAll() optimizations [v7]

jengebr duke at openjdk.org
Mon Nov 17 15:42:37 UTC 2025


On Fri, 14 Nov 2025 21:59:00 GMT, Chen Liang <liach at openjdk.org> wrote:

>> jengebr has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Polishing test and benchmark
>
> src/java.base/share/classes/java/util/Collections.java line 5264:
> 
>> 5262:         public <T> T[] toArray(T[] a) {
>> 5263:             if (a.length < 1)
>> 5264:                 a = (T[])java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), 1);
> 
> Suggestion:
> 
>                 a = (T[]) Array.newInstance(a.getClass().getComponentType(), 1);

Fixed

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

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


More information about the core-libs-dev mailing list