RFR: JDK-8319123 : Implementation of JEP-461: Stream Gatherers (Preview)

Viktor Klang vklang at openjdk.org
Wed Nov 8 15:41:41 UTC 2023


On Wed, 8 Nov 2023 14:14:35 GMT, Tagir F. Valeev <tvaleev at openjdk.org> wrote:

>> I've thought about that, and since we don't use that for the other parameters (like `initializer`) I don't think it helps changing it here. And the reason this has little effect is that the code calling the factory typically controls the components/parameters/return type.
>
> It's still possible to have a situation where PECS signature could be useful, and I don't see any downsides. A user may want to reuse the same static integrator instead of creating several identical lambdas just because the target type is more specific. Sometimes, people complain later, and you'll have to fix this. For example, see that `Stream.generate()` [was fixed separately](https://bugs.openjdk.org/browse/JDK-8132097). So why not doing this from the very beginning?

@amaembo In this case, given that it is intended as Preview, I think it makes sense to receive some user feedback on this. Note that Collector has been without PECS for Collector.of since 1.8: [of](https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collector.html#of-java.util.function.Supplier-java.util.function.BiConsumer-java.util.function.BinaryOperator-java.util.function.Function-java.util.stream.Collector.Characteristics...-)

Right now I don't want to deviate from the Collector-heritage until there's more usage feedback, and I'm definitely not ruling out that PECS:ing the factories might be worth it.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16420#discussion_r1386788253


More information about the core-libs-dev mailing list