On Fri, 28 Oct 2022 19:57:41 GMT, Rémi Forax <fo...@openjdk.org> wrote:
>> `List.of()` can't be used here, since the elements are nullable, according >> to the documentation. But the the returned list can still be modified, by >> changing the given `elements` array. The input array must be explicitly >> copied: >> >> public static <E> List<E> toList(E... elements) { >> return Collections.unmodifiableList(new >> ArrayList<>(Arrays.asList(elements))); >> } > > Yes, it only occurs to me mid review, that said there is already an > implementation in the jdk of a compact immutable that allow null inside the > JDK (this implementation is used when stream.toList() is used). > Using that implementation will avoid a bunch of indirection Changing to use `JUCA`. ------------- PR: https://git.openjdk.org/jdk/pull/10889