From b68356b267ad8f2da0d4f84de82b3b0042b4acd0 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 29 Nov 2023 17:25:26 +0000 Subject: [PATCH] 8320806: Augment test/langtools/tools/javac/versions/Versions.java for JDK 22 language changes Reviewed-by: jlahoda, vromero --- .../tools/javac/versions/Versions.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/test/langtools/tools/javac/versions/Versions.java b/test/langtools/tools/javac/versions/Versions.java index ee9e6f2be06..554d384948b 100644 --- a/test/langtools/tools/javac/versions/Versions.java +++ b/test/langtools/tools/javac/versions/Versions.java @@ -25,7 +25,7 @@ * @test * @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 * 8000961 8030610 8028546 8188870 8173382 8173382 8193290 8205619 8028563 - * 8245147 8245586 8257453 8286035 8306586 + * 8245147 8245586 8257453 8286035 8306586 8320806 * @summary Check interpretation of -target and -source options * @modules java.compiler * jdk.compiler @@ -272,8 +272,8 @@ public class Versions { * the uncommon program that is accepted in one version of the * language and rejected in a later version.) * - * When version of the language get a new, non-preview feature, a - * new source example enum constant should be added. + * When a version of the language gets a new, non-preview feature, + * a new source example enum constant should be added. */ enum SourceExample { BASE(7, "Base.java", "public class Base { }\n"), @@ -375,6 +375,20 @@ public class Versions { } """), + SOURCE_22(22, "New22.java", + // New feature in 22: Unnamed Variables & Patterns + """ + public class New22 { + public static void main(String... args) { + Object o = new Object(){}; + + System.out.println(switch (o) { + case Integer _ -> "Hello world."; + default -> o.toString(); + }); + } + } + """), ; // Reduce code churn when appending new constants private int sourceLevel;