patterns: run Guards, NullCase and MatchException demos on 21 too; add switch-on-long check

Adds broken/SwitchOnLong.java and regenerates transcripts so every 'runs on 21, 25 and 27' claim has a transcript. Additive commit.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
This commit is contained in:
Claude
2026-09-24 11:54:48 +00:00
parent bc91b9c8d0
commit 65a4bbbbe3
6 changed files with 52 additions and 3 deletions
+4 -3
View File
@@ -31,10 +31,10 @@ all3() { local fn="$1"; shift; [ -n "$JDK21" ] && { "$fn" "$JDK21" "$@"; echo; }
{ all3 cr src/TypePatterns.java TypePatterns; } > "$OUT/01-type-patterns.txt"
# 02 - guards and dominance
{ both cr src/Guards.java Guards; echo; both co broken/Dominated.java; echo; both co broken/GuardBeforeGeneral.java; } > "$OUT/02-guards-and-dominance.txt"
{ all3 cr src/Guards.java Guards; echo; both co broken/Dominated.java; echo; both co broken/GuardBeforeGeneral.java; } > "$OUT/02-guards-and-dominance.txt"
# 03 - record patterns, and what happens when an accessor throws
{ all3 cr src/RecordPatterns.java RecordPatterns; echo; both cr src/MatchExceptionDemo.java MatchExceptionDemo; } > "$OUT/03-record-patterns.txt"
{ all3 cr src/RecordPatterns.java RecordPatterns; echo; all3 cr src/MatchExceptionDemo.java MatchExceptionDemo; } > "$OUT/03-record-patterns.txt"
# 04 - exhaustiveness: the compiler's check, and what separate compilation can still break
{ all3 cr src/SealedExhaustive.java SealedExhaustive; echo
@@ -51,10 +51,11 @@ all3() { local fn="$1"; shift; [ -n "$JDK21" ] && { "$fn" "$JDK21" "$@"; echo; }
done; } > "$OUT/05-separate-compilation.txt"
# 06 - null and unnamed patterns
{ both cr src/NullCase.java NullCase; echo; all3 cr src/Unnamed.java Unnamed; } > "$OUT/06-null-and-unnamed.txt"
{ all3 cr src/NullCase.java NullCase; echo; all3 cr src/Unnamed.java Unnamed; } > "$OUT/06-null-and-unnamed.txt"
# 07 - primitive patterns (preview)
{ for f in PrimitiveInstanceof; do both co preview/$f.java; done; echo
all3 co broken/SwitchOnLong.java; echo
for f in PrimitiveInstanceof PrimitiveSwitch PrimitiveInRecord PrimitiveEdges; do both crp preview/$f.java $f; echo; done
both crp preview/BoxedToNarrower.java BoxedToNarrower; } > "$OUT/07-primitive-patterns.txt"
{ o="$(mk)"; "$JDK25/bin/javac" --enable-preview --release 25 -d "$o" preview/PrimitiveSwitch.java 2>&1 | grep -v '^Note:'