On Fri, 4 Sep 2026 17:59:47 GMT, Naoto Sato <[email protected]> wrote:
>> Note that `List.copyOf(…)` should probably be improved to trust the return >> value of `List::toArray()` when the list implementation’s class is exactly >> `ArrayList.class`[^1][^2]: >> - https://github.com/openjdk/jdk/pull/32282#discussion_r3774849249 >> >> -------------------------------------------------------------------------------- >> >> Also, +1 to introducing `SequencedMap::of(…)` and `SequencedSet::of(…)`. >> >> [^1]: And probably some other well‑known and trusted JDK list >> implementations. >> [^2]: The same should probably also be done with >> [`MethodType.methodType(Class, List)`]. >> >> [`MethodType.methodType(Class, List)`]: >> https://docs.oracle.com/en/java/javase/26/docs/api/java.base/java/lang/invoke/MethodType.html#methodType(java.lang.Class,java.util.List) > > Thanks for the suggestion. Since it would require access to `SharedSecrets`, > we'll consider that level of performance improvement once the API is no > longer incubating. @naotoj I was talking about doing the optimisation inside `java.util.ImmutableCollections::listCopy(…)`, which is called by `java.util.List::copyOf(…)`: https://github.com/openjdk/jdk/blob/a48203f498fd55ae7ee8f1f38c2ed0b6224d41c6/src/java.base/share/classes/java/util/ImmutableCollections.java#L182-L190 ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/32282#discussion_r3952193787
