Which stream operations use `CONCURRENT`,`IMMUTABLE` and `NONNULL` Spliterator characteristics?

Viewed 452

Which stream operations use CONCURRENT,IMMUTABLE and NONNULL Spliterator characteristics? How does each of them help in those operations?


I'm not asking what those flags are, this can be found easly in the documantation. I'm asking which operations use them and how.

3 Answers

People say that IMMUTABLE isn't used but as it turns out, Stream#iterate reports IMMUTABLE:

jshell> Stream.iterate(0, i -> i + 1).spliterator().characteristics()
$1 ==> 1040

1040 is IMMUTABLE | ORDERED but it looks like any operation drops IMMUTABLE (tested with map, filter, flatMap, limit, skip; tested on Java 16)
IntStream#iterate, LongStream#iterate and DoubleStream#iterate report NONNULL as well but that is also dropped by the next operation.

Related