Skip to content

Commit ed2494f

Browse files
wenytang-msCopilot
authored andcommitted
Update Java 26 tests with JEP 530 (Primitive Types in Patterns) coverage
Replace generic test files from #3740 with JEP 530-specific test cases: - Foo.java: primitive type pattern in switch with when guard - Bar.java: instanceof with primitive type pattern - Update target platform JRE to JavaSE-26 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a95c217 commit ed2494f

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

  • org.eclipse.jdt.ls.tests/projects
    • eclipse/java26/src/main/java/foo/bar
    • maven/salut-java26/src/main/java/org/sample

org.eclipse.jdt.ls.tests/projects/eclipse/java26/src/main/java/foo/bar/Foo.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
* It's a Foo class
55
*/
66
public class Foo {
7-
public Foo() {
8-
System.out.println();
9-
super();
7+
// JEP 530: Primitive Types in Patterns, instanceof, and switch (Fourth Preview)
8+
static String classify(int value) {
9+
return switch (value) {
10+
case 0 -> "zero";
11+
case int i when i > 0 -> "positive";
12+
case int i -> "negative";
13+
};
1014
}
1115
}

org.eclipse.jdt.ls.tests/projects/maven/salut-java26/src/main/java/org/sample/Bar.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
*/
66
public class Bar {
77

8+
// JEP 530: Primitive Types in Patterns, instanceof, and switch (Fourth Preview)
89
public static void main(String[] args) {
9-
Object foo = "x";
10-
if (foo instanceof String str) {
11-
System.out.println(str);
10+
Object obj = 42;
11+
if (obj instanceof int i) {
12+
System.out.println("int value: " + i);
1213
}
1314
}
1415
}

0 commit comments

Comments
 (0)