Workbench / The TiffinBox Build
S40 · V3·39
The Next JDK
Volume 3, chapter 39. TiffinBox compiles with --release 21, so it should build on JDK 25 unchanged. It didn't: javac 23 added a warning, dangling-doc-comments, and -Werror turned two misplaced comments into a failed build; one had left minusFloorZero undocumented since Volume 1. With those fixed, everything passes on JDK 25: 51 core and 46 server tests, the golden master, the suite. On the way, the release log showed that 0.2.0 had shipped saying it was 0.1.0. This stage adds a JDK matrix to the release check and makes the version a build output.
Stage 40: the next JDK
The brief
What you'll build.
tools/jdk-matrix.sh: builds LangLint, core, server andtbxand runs the golden master with each JDK inJDKS, each in its own copy of the tree; the release check runs it whenJDKSis set;- the two fixes javac 25 asked for: the doc comments in
MoneyandOrderLogmoved to their declarations; - the version from the build: a
VERSIONfile (0.3.0-dev), written into the jar's manifest bybuild.sh, read withPackage.getImplementationVersion();/versionadds the JDK (Runtime.version()); the release check fails on a mismatch; the golden master normalises the JDK; - an upgrade measurement (
exp/40/upgrade.sh): the same jar on JDK 21, JDK 25, and JDK 25 with compact object headers.
Why a real company needs this. JDK upgrades are routine every two years and possible every six months. Teams that build on the next JDK continuously find a warning or a removed flag the week it appears; teams that don't find twenty at once, under a deadline. And every incident starts with "what's running?", which a hand-edited constant answers wrongly.
Why now. Chapter 39 is modern Java: the release train and previews, records, sealed types and pattern matching, sequenced collections and new APIs, modules, and runtime changes. TiffinBox already uses most of the language features; this stage applies the chapter's other half, the process of keeping up.
What you'll have at the end.
- a build that is green on JDK 21 and JDK 25, checked by one command;
- a server that says which version and which JDK it is, and a release check that holds it to that;
- measured upgrade numbers for TiffinBox itself;
- ADR-0042: supported JDKs and versioning.
Theory to own
--release. What does--release 21guarantee when compiling with javac 25, and what doesn't it? (The chapter's lab, Experiment 1; Companion, Gaps 1 and 2.)- Compatibility layers. Source, binary, behavioural, tooling: which did JDK 25 break here? (Companion, Theoretical gaps 1.)
- Where a version comes from. Why is a constant in the code the wrong place? (Companion, Gaps 3.)
- Measuring memory. What does "heap used" mean before and after a GC? (Companion, Gaps 4.)
Build it
Step 1: build on the next JDK
Download a JDK 25 (Temurin 25.0.1 here), write tools/jdk-matrix.sh, and run it with JDKS naming JDK 21 and 25.
Checkpoint. exp/40/matrix-before.txt.
Step 2: fix what the new compiler found
Read both warnings and move each comment to the declaration it describes.
Checkpoint. exp/40/matrix-after.txt: every column ok for both JDKs.
Step 3: the version, from the build
Add VERSION; in server/build.sh, write Implementation-Title and Implementation-Version into out/MANIFEST.MF and pass --manifest to jar; read it in Server.VERSION (falling back to "dev"); add Runtime.version() to /version; normalise (Java …) in the golden master; make the release check compare /version with VERSION.
Checkpoint. exp/40/version-after.txt; exp/40/golden-diff.txt; the golden master re-recorded.
Step 4: what the upgrade buys
Run exp/40/upgrade.sh: start the server on each runtime, time the first /health, place 2,000 orders with the simulator, then read RSS and the heap after a full GC; twice.
Checkpoint. exp/40/upgrade.out.
Senior and architect lens
1. Run the next JDK before you need it. The matrix costs a minute per JDK. Run it whenever the build changes and at every JDK release, and the upgrade becomes a list of small fixes instead of a project.
2. ADR-0042: supported JDKs and versioning. Write it with these points:
- Runtime: JDK 21 is the minimum and the
--release; JDK 25 is tested in the matrix; the next LTS is added when its first build is available. - Lint:
-Xlint:all -Werrorstays, and new categories are fixed, not disabled, unless a decision says otherwise. - Toolchain: the JDK that builds a release is recorded (the manifest's
Created-By), because builds are reproducible only with it pinned. - Version: one
VERSIONfile; the jar's manifest carries it;/versionreports it with the JDK; the release check fails on any mismatch.
3. The version is evidence, not decoration. It's the first fact in every incident and support case; a wrong one sends people to the wrong code.
What breaks first, and when it's addressed:
| Pressure | What breaks | Where it's addressed |
|---|---|---|
| the matrix needs JDKs installed | it runs only where JDKS is set |
stage 44 (build systems: toolchains) |
| the commit isn't in the version | two builds of 0.3.0-dev look the same |
stage 44 (build systems: build info) |
| JVM flags that a newer JDK removes | the server refuses to start | stage 41 (JVM internals: flags and startup) |
| memory measured once | numbers that mislead | stage 42 (memory and performance: GC logs, JFR) |
Evidence
exp/40/matrix-before.txtshows JDK 25 failing;matrix-after.txtallok.exp/40/dangling.out: javac 21 silent, javac 25 warning, javadoc losing the first comment.exp/40/version-after.txt;golden-diff.txt(12 lines, version only);golden master: 47 exchanges, identicalafter re-recording.exp/40/upgrade.outmeasured after a full GC, twice.- core 51, server 46 tests and the suite's 44 pass on JDK 21 and 25.
- ADR-0042 is committed.
Carry forward
tools/jdk-matrix.shruns in every release check from here on (JDKSset).VERSIONis bumped by the release process only (0.3.0at the end of Volume 3).- Live heap after a full GC is how memory is compared from now on (stage 42).