<i18n dev> RFR: 8263561: Re-examine uses of LinkedList

Yi Yang yyang at openjdk.java.net
Sun Mar 14 17:10:24 UTC 2021

On Fri, 26 Feb 2021 10:48:33 GMT, Сергей Цыпанов <github.com+10835776+stsypanov at openjdk.org> wrote:

> The usage of `LinkedList` is senseless and can be replaced with either `ArrayList` or `ArrayDeque` which are both more compact and effective.
> jdk:tier1 and jdk:tier2 are both ok

src/java.base/share/classes/jdk/internal/loader/URLClassPath.java line 220:

> 218:             return Collections.emptyList();
> 219:         }
> 220:         List<IOException> result = new ArrayList<>();

We'd better be cautious about this replacement since its [caller](https://github.com/openjdk/jdk/blob/73029fe10a8a814a8c5f5221f2e667fd14a5b379/src/java.base/share/classes/java/net/URLClassLoader.java#L363) will remove the first element of this array, that's one of the scenarios where LinkedList usually has better performance than ArrayList.

Just IMHO, I suggest replacing them only if there is a performance improvement(e.g. benchmark reports). Changing field types will break users' existing application code, they might reflectively modify these values.


PR: https://git.openjdk.java.net/jdk/pull/2744

More information about the i18n-dev mailing list