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
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
$ java -cp old Client (Client and Shape compiled together, v1) (25.0.4.1+1-LTS)
|
||||
circle: 3.141592653589793
|
||||
square: 4.0
|
||||
|
||||
$ java -cp new:old Main (Shape gained Triangle; Client.class NOT recompiled) (25.0.4.1+1-LTS)
|
||||
Exception in thread "main" java.lang.MatchException
|
||||
at Client.area(Client.java:4)
|
||||
at Main.main(Main.java:4)
|
||||
|
||||
$ javac -cp new sep/client/Client.java (now recompile Client against v2) (25.0.4.1+1-LTS)
|
||||
sep/client/Client.java:4: error: the switch expression does not cover all possible input values
|
||||
return switch (s) {
|
||||
^
|
||||
1 error
|
||||
|
||||
$ java -cp old Client (Client and Shape compiled together, v1) (27+35)
|
||||
circle: 3.141592653589793
|
||||
square: 4.0
|
||||
|
||||
$ java -cp new:old Main (Shape gained Triangle; Client.class NOT recompiled) (27+35)
|
||||
Exception in thread "main" java.lang.MatchException
|
||||
at Client.area(Client.java:4)
|
||||
at Main.main(Main.java:4)
|
||||
|
||||
$ javac -cp new sep/client/Client.java (now recompile Client against v2) (27+35)
|
||||
sep/client/Client.java:4: error: the switch expression does not cover all possible input values
|
||||
return switch (s) {
|
||||
^
|
||||
missing patterns:
|
||||
Triangle _
|
||||
1 error
|
||||
|
||||
Reference in New Issue
Block a user