On Tue, 4 Jun 2024 19:41:15 GMT, Doug Lea <d...@openjdk.org> wrote:

>> src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java 
>> line 103:
>> 
>>> 101:     private static final long serialVersionUID = 8673264195747942595L;
>>> 102: 
>>> 103:     private static final Object[] EMPTY_ELEMENTDATA = {};
>> 
>> Looks like readObject() ought to also be changed to use the 
>> EMPTY_ELEMENTDATA if the length of the read array is 0? And perhaps 
>> `clone()`.
>
> Agreed. You might as well be consistent with this so that no one will need to 
> re-address if some application does zillions of clones of empty lists.

I've updated `readObject` to match - thanks!  `clone()` isn't a big win since 
the array is allocated elsewhere and the application doesn't use that code 
path, so I'll leave that alone for now.

Sorry, I crossed wires with @DougLea 's comment, will add `clone`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19527#discussion_r1626537384
PR Review Comment: https://git.openjdk.org/jdk/pull/19527#discussion_r1626538689

Reply via email to