[PATCH] JDK-8134373: explore potential uses of convenience factories within the JDK

Jonathan Bluett-Duncan jbluettduncan at gmail.com
Sat Sep 10 23:42:47 UTC 2016

Hi all,

Would you kindly review this patch to replace existing uses of
Collections.unmodifiable*(*Arrays.asList(*)) and plain Arrays.asList(*)
with (List|Set|Map).of(*). You may find the patch files in the attachments.

My rationale for replacing uses of Collections.unmodifiable*... with
(List|Set|Map).of is to make use of the memory savings allowed by the newer

The general rationale for replacing the Arrays.asList calls I've touched is
to again make use of memory savings, but this may be naive or misguided
reasoning on my part, as Arrays.asList may or may not be more
memory-efficient than List.of. However, where I've replaced Arrays.asList
for List.of in FileTreeIterator, my reasoning for doing so instead was to
help prevent TOCTOU attacks, but again this may be misguided on my part.

It doesn't seem practical to me to include new unit tests, as these are
mainly performance improvements, but if it's believed that new unit tests
are needed, then I'd be happy to go back and try to include some.

Kind regards,

More information about the core-libs-dev mailing list