Have you ever wanted to perform an operation on a java.util.stream.Stream only to find that the existing set of intermediate operations didn't provide what you needed? While the Streams API offers a rich set of operations out of the box, it was always envisioned to offer the capability for user-defined intermediate operations, yet at that time the right way to expose that hadn't been discovered. Until now... In this session, we'll demonstrate Gatherers, an API made final through JEP 485 in Java 24, to create, use, re-use, and compose intermediate operations for java.util.stream.Stream, enabling custom transformations as natural steps in your day-to-day stream processing.
Presented by Viktor Klang - Software Architect (Java Platform Group - Oracle) at JavaOne 2025 (CA, March 2025).
All JavaOne 2025 talks ➤ https://www.youtube.com/playlist?list=PLX8CzqL3ArzVV1xRJkRbcM2tOgVwytJAi
➤ https://openjdk.org/jeps/485
➤ https://inside.java
➤ https://dev.java
━━ Chapters ━━
• 00:00 Intro
• 00:22 Java Stream Anatomy
• 02:03 Intermediate Stream Operation?
• 02:28 Growing an API
• 09:08 Evaluating Collector against the requirements
• 10:29 Stream Gatherers
• 12:37 Gatherers vs. Collectors
• 15:20 Example - Stream::map as a Gatherer
• 17:20 Example - Stream::mapMulti as a Gatherer
• 18:08 Example - Stream::limit as a Gatherer
• 21:21 Sequential vs. Parallel Evaluation
• 29:16 Some of the available java.util.stream.Gatherers
• 33:25 A note on composition
• 35:44 Conclusions
• 36:45 Q&A
Tags: #Java #JavaOne #openjdk
SES1641