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:
Claude
2026-09-24 11:50:40 +00:00
parent 96b25c8fc4
commit bc91b9c8d0
36 changed files with 736 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
public class PrimitiveEdges {
public static void main(String[] args) {
double[] ds = {0.0, -0.0, Double.NaN, 16777217.0, 1e10, 3.0};
for (double d : ds) {
System.out.printf("%-12s int? %-5b float? %-5b%n", d, d instanceof int, d instanceof float);
}
long big = 1L << 40;
System.out.println(big + " instanceof int? " + (big instanceof int));
Object o = 42;
if (o instanceof int i) System.out.println("Object holding Integer matches int pattern: " + i);
Object s = (short) 7;
if (s instanceof int i) System.out.println("Short in Object matches int? " + i); else System.out.println("Short in Object does not match int");
int x = 65;
if (x instanceof char c) System.out.println("65 as char: " + c);
}
}