Files
javademos/patterns/output/04-exhaustiveness.txt
T
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

55 lines
1.8 KiB
Plaintext

$ javac src/SealedExhaustive.java && java SealedExhaustive (21.0.10+7-Ubuntu-124.04)
Circle[r=1.0] -> 3.14
Square[side=2.0] -> 4.00
Rect[w=2.0, h=3.0] -> 6.00
$ javac src/SealedExhaustive.java && java SealedExhaustive (25.0.4.1+1-LTS)
Circle[r=1.0] -> 3.14
Square[side=2.0] -> 4.00
Rect[w=2.0, h=3.0] -> 6.00
$ javac src/SealedExhaustive.java && java SealedExhaustive (27+35)
Circle[r=1.0] -> 3.14
Square[side=2.0] -> 4.00
Rect[w=2.0, h=3.0] -> 6.00
$ javac broken/NotExhaustive.java (21.0.10+7-Ubuntu-124.04)
broken/NotExhaustive.java:8: error: the switch expression does not cover all possible input values
return switch (s) {
^
1 error
$ javac broken/NotExhaustive.java (25.0.4.1+1-LTS)
broken/NotExhaustive.java:8: error: the switch expression does not cover all possible input values
return switch (s) {
^
1 error
$ javac broken/NotExhaustive.java (27+35)
broken/NotExhaustive.java:8: error: the switch expression does not cover all possible input values
return switch (s) {
^
missing patterns:
Rect _
1 error
$ javac broken/NotExhaustiveObject.java (21.0.10+7-Ubuntu-124.04)
broken/NotExhaustiveObject.java:3: error: the switch expression does not cover all possible input values
return switch (o) {
^
1 error
$ javac broken/NotExhaustiveObject.java (25.0.4.1+1-LTS)
broken/NotExhaustiveObject.java:3: error: the switch expression does not cover all possible input values
return switch (o) {
^
1 error
$ javac broken/NotExhaustiveObject.java (27+35)
broken/NotExhaustiveObject.java:3: error: the switch expression does not cover all possible input values
return switch (o) {
^
missing patterns:
Object _
1 error