Files
Claude bc91b9c8d0 Add patterns module: pattern matching from JDK 21 to 27
Type, record and primitive patterns, guards, sealed exhaustiveness, MatchException via separate compilation, and eight captured transcripts.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
2026-09-24 11:50:40 +00:00

16 lines
865 B
Markdown

# patterns — Pattern matching from JDK 21 to 27
Companion code for the ankurm.com article **Pattern Matching in Java: switch, Record Patterns and Primitive Patterns (JDK 21 to 27)**. The explanation
lives in the article; this folder holds the runnable sources and the transcripts they produced.
```bash
JDK25=/path/to/jdk-25 JDK27=/path/to/jdk-27 [JDK21=/path/to/jdk-21] ./run.sh # regenerates output/*.txt
```
- `src/` compiles and runs on 21, 25 and 27 (except `Unnamed.java`, which needs 22 or later).
- `broken/` fails to compile on purpose.
- `preview/` uses primitive patterns (JEP 532, preview in 27) and needs `--enable-preview --release N`.
- `sep/` is a sealed hierarchy compiled in two versions, to show the one runtime failure an exhaustive `switch` cannot prevent.
Tested on Temurin 25.0.4.1+1 and 27+35, and OpenJDK 21.0.10 for the baseline.