RFR: 8281289: Improve with List.copyOf

Claes Redestad redestad at openjdk.java.net
Sat Feb 5 13:25:12 UTC 2022


On Fri, 4 Feb 2022 23:02:21 GMT, Xue-Lei Andrew Fan <xuelei at openjdk.org> wrote:

> Please review this trivial code clean up, for a little bit better performance.

There's a small compatibility risk with this change, e.g., `List.copyOf(...).contains(null)` will throw NPE while `Collections.unmodifiableList(...).contains(null)` won't.

If we accept that compatibility risk (which should probably be decided by CSR) it might also make sense to use `List.of()` for the empty case, which will reduce the number of List implementation classes returned from the API.

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

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



More information about the security-dev mailing list