RFR: 8376406: Avoid loading ArrayDeque in jdk.internal.loader.NativeLibraries [v2]
Eirik Bjørsnøs
eirbjo at openjdk.org
Fri Feb 20 13:25:17 UTC 2026
On Fri, 20 Feb 2026 13:07:43 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> The `ArrayDeque()` constructor takes the number of "elements" whereas `ArrayList()` constructor takes the initial capacity.
They both seem to allocate Object arrays to fit elements. ArrayList makes an array for 8 objects, ArrayDeque 8 + 1.
> Having said that, I can't see why this `8` was used in the first place.
> If we are going to change this to an ArrayList, maybe we should just change this to new ArrayList<>().
Sounds reasonable, that would allow `isEmpty()` checks on an empty list to avoid allocation. If that matters.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29432#discussion_r2833180523
More information about the core-libs-dev
mailing list