JEP 461: Breathing New Life into Java Stream API
summary
JEP 461 introduces gather, an intermediate collect-like operation shipped as a Java 22 preview that adds short-circuiting and streaming-first result types. Five built-ins arrive: windowFixed, windowSliding, fold, scan and mapConcurrent; mapConcurrent runs on virtual threads, accepts a maxConcurrency and avoids the ForkJoinPool pitfalls. The integrator returns true/false to continue or stop, enabling zipWithIndex, iterator zips, distinctBy, and last(n) to be implemented as custom gatherers — live-coding shows these work and a companion library “more-gatherers” collects additional useful operators.
AI-written summary · about
chapters (12)
- 0:00Introduction to JEP 461
- 1:16Stream API basics recap
- 8:41Limitations of collectors
- 9:44Introducing gather method
- 11:54Anatomy of collector vs gutter
- 16:34Predefined gutters overview
- 20:55Map concurrent with virtual threads
- 26:14Parallel streams limitations
- 29:25Custom gutter implementation
- 38:32Distinct by property gutter
- 42:06Last N elements gutter
- 44:36Future of gutters and Q&A
related talks
40mStream Gathers - The biggest change to Java Streams since 10 years
44mLevel Up Your Java Streams with Gatherers
43mStream Gatherers - Deep Dive with the Expert
45mStream Gatherers
48mWe Are All Gathered — We Are All to Gather
39mLevel Up Your Java Streams with Gatherers
52mThe Gatherer API: the tool that was missing in the Stream API
51mHunting with Stream Gatherers
