Add java17-features module: runnable demos and captured output for the ankurm.com java17-features article

This commit is contained in:
2026-10-20 17:13:58 +00:00
parent 8b9447a393
commit 5a076c826f
23 changed files with 261 additions and 0 deletions
@@ -0,0 +1,18 @@
$ javac broken/SealedViolation.java (17.0.20.1)
broken/SealedViolation.java:5: error: class is not allowed to extend sealed class: Shape (as it is not listed in its permits clause)
record Triangle(double b, double h) implements Shape {}
^
1 error
$ javac broken/RecordFieldMutation.java (17.0.20.1)
broken/RecordFieldMutation.java:3: error: cannot assign a value to final variable x
record Point(int x, int y) { void move() { this.x = 10; } }
^
1 error
$ javac broken/SwitchPatternOn17.java (17.0.20.1)
broken/SwitchPatternOn17.java:3: error: patterns in switch statements are a preview feature and are disabled by default.
static String f(Object o) { return switch (o) { case String s -> "string"; default -> "other"; }; }
^
(use --enable-preview to enable patterns in switch statements)
1 error