Add two standalone modules: Stream Gatherers (JEP 485) and Scoped Values vs ThreadLocal (JEP 506)

gatherers/: windowFixed, windowSliding, fold, scan, mapConcurrent, a custom
Gatherer (dedupeConsecutive, takeUntil), and a Collector-vs-Gatherer comparison.
Verified: windowSliding emits one short window on a too-short stream rather than
shrinking to empty like windowFixed; mapConcurrent waits for in-flight siblings
to finish (~901ms) rather than cancelling them when one mapper throws.

scoped-values/: ScopedValue API and rebinding, why plain threads (virtual or
platform) do not inherit a binding while a StructuredTaskScope subtask does,
and the memory cost vs InheritableThreadLocal measured two ways -- a noisy
heap-delta first pass, then a precise jcmd GC.class_histogram object census
(5 shared Carrier objects vs ~700,000 copied ThreadLocalMap/Entry objects for
100,000 threads).

Companion code for the ankurm.com posts "Java Stream Gatherers (JEP 485)" and
"Scoped Values vs ThreadLocal in Java 25: Migration Guide with Virtual Threads".

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FtpJvZfg4nvLvtzgJTDWpB
This commit is contained in:
Claude
2026-09-24 04:27:12 +00:00
parent f59c1de96d
commit 6b5a918278
25 changed files with 1124 additions and 5 deletions
+11 -3
View File
@@ -1,7 +1,8 @@
# javademos
Runnable companion code for the ankurm.com post **"Java 27 Is Out: Every JEP, Plus the Java 26 Changes You Skipped"**, and for the Java version guides
(<https://ankurm.com/java-21-to-25-lts-features/>). Every number and transcript in the post comes from a file in `docs/output/`, produced by a script in `scripts/`.
Runnable companion code for the ankurm.com post **"Java 27 Is Out: Every JEP, Plus the Java 26 Changes You Skipped"**, for the Java version guides
(<https://ankurm.com/java-21-to-25-lts-features/>), and for two standalone deep dives: **Stream Gatherers (JEP 485)** and **Scoped Values vs
ThreadLocal (JEP 506)**. Every number and transcript in the post comes from a file in `docs/output/`, produced by a script in `scripts/`.
## What was tested against
@@ -15,7 +16,8 @@ Runnable companion code for the ankurm.com post **"Java 27 Is Out: Every JEP, Pl
| JOL | 0.17 | downloaded and sha1-checked by `scripts/object-headers.sh` |
Next LTS: Java 29, September 2027 (Oracle Java SE Support Roadmap). Layout: `g1-container/`, `object-headers/`, `jep-tour/` (27 features and `broken/` 26-era sources),
`recap26/` (the Java 26 lane), `lanes/` (the 21 to 25 hub demos, the AI prompts in `lanes/prompts/` and the build-file demo in `lanes/upgrade/`), `other-changes/`, `api-diff/`.
`recap26/` (the Java 26 lane), `lanes/` (the 21 to 25 hub demos, the AI prompts in `lanes/prompts/` and the build-file demo in `lanes/upgrade/`), `other-changes/`, `api-diff/`,
`gatherers/` (JEP 485, standalone post), `scoped-values/` (JEP 506 vs `ThreadLocal`, standalone post).
## Quickstart
@@ -25,6 +27,8 @@ export JDK21=/path/to/jdk-21 JDK25=/path/to/jdk-25 JDK26=/path/to/jdk-26 JDK27=/
./scripts/recap26.sh # the 26 recap lane
./scripts/lanes.sh # the 21 to 25 hub claims, checked on 21, 23, 24, 25, 26, 27
./scripts/upgrade.sh # the build-file half: Maven, Gradle, Lombok, --release, jdeps (needs Maven Central)
./scripts/gatherers.sh # Stream Gatherers (JEP 485): every built-in gatherer, a custom one, mapConcurrent
./scripts/scoped-values.sh # Scoped Values vs ThreadLocal (JEP 506): API, inheritance, memory (needs jcmd on PATH)
./scripts/run-all.sh # regenerate every docs/output/*.txt (about 15-20 minutes; needs Docker)
```
@@ -49,6 +53,8 @@ Timings, RSS, GC counts and the Vector species are machine dependent; treat them
| 13 | [Upgrade checklist](docs/13-upgrade-checklist.md) |
| 14 | [The 21 to 25 lane: every claim in the hub posts, checked](docs/14-lanes-21-to-25.md) |
| 15 | [Build files: Maven, Gradle and Lombok on the way to 25](docs/15-build-files.md) |
| 16 | [Stream Gatherers (JEP 485)](docs/16-gatherers.md) |
| 17 | [Scoped values vs ThreadLocal (JEP 506)](docs/17-scoped-values-migration.md) |
## Captured output (`docs/output/`)
@@ -66,6 +72,8 @@ Timings, RSS, GC counts and the Vector species are machine dependent; treat them
| `70`-`75` | `recap26.sh` | final-field mutation, AOT cache matrix and startup, removals, 26 API, HTTP/3 |
| `92`-`97` | `upgrade.sh` | Maven release 25 on JDK 21, 25, 27, Gradle 8 vs 9 on JDK 25, `--release` vs `-source/-target`, Lombok and Mockito by version, `jdeps --jdk-internals` |
| `80`-`91` | `lanes.sh` | the 21 to 25 hub claims on JDK 21, 23, 24, 25, 26, 27: scoped values, structured concurrency, finalization, pinning, ZGC flags, warnings |
| `98` | `gatherers.sh` | the four built-in gatherers, `mapConcurrent` + virtual threads, a custom `Gatherer`, Collector vs Gatherer |
| `99` | `scoped-values.sh` | `ScopedValue` API and rebinding, why plain threads don't inherit a binding, memory vs `ThreadLocal` two ways (heap delta, then `jcmd` object census) |
## Not reproduced