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

Сергей Цыпанов github.com+10835776+stsypanov at openjdk.java.net
Sun Mar 14 17:21:11 UTC 2021

On Sun, 14 Mar 2021 15:02:03 GMT, liach <github.com+7806504+liach at openjdk.org> wrote:

>> 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.
> If that's the only use case, I recommend changing the return type to a deque, and replace the linked list with an array deque instead (as done elsewhere in this pr)

Looks like it's never specified in JavaDoc which particular implementation of List is used in fields of affected classes, so it's quite odd to me that someone would rely on that when using reflection. But your point about backward compatibility is reasonable, so I'll revert mentioned changes.


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

More information about the i18n-dev mailing list