-
Bug
-
Resolution: Fixed
-
P3
-
21
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8320764 | 21.0.2 | Jan Lahoda | P3 | Resolved | Fixed | b09 |
ADDITIONAL SYSTEM INFORMATION :
java version "21" 2023-09-19 LTS
A DESCRIPTION OF THE PROBLEM :
Try running the following code:
Expected result on stdout: A
Actual result: JVM throws MatchException
REGRESSION : Last worked in version 17.0.8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run provided example code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Stdout should read "A"
ACTUAL -
JVM throws MatchException
---------- BEGIN SOURCE ----------
public class Main
{
public enum Test {
A {}, B {}, C {}
}
public static void main(String[] args)
{
Test x = get();
switch (x) {
case A -> System.out.println("A");
case B -> System.out.println("B");
case C -> System.out.println("C");
case null -> System.out.println("NULL");
}
}
private static Test get() {
return Test.A;
}
}
---------- END SOURCE ----------
FREQUENCY : always
java version "21" 2023-09-19 LTS
A DESCRIPTION OF THE PROBLEM :
Try running the following code:
Expected result on stdout: A
Actual result: JVM throws MatchException
REGRESSION : Last worked in version 17.0.8
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run provided example code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Stdout should read "A"
ACTUAL -
JVM throws MatchException
---------- BEGIN SOURCE ----------
public class Main
{
public enum Test {
A {}, B {}, C {}
}
public static void main(String[] args)
{
Test x = get();
switch (x) {
case A -> System.out.println("A");
case B -> System.out.println("B");
case C -> System.out.println("C");
case null -> System.out.println("NULL");
}
}
private static Test get() {
return Test.A;
}
}
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8320764 Match on enum constants with body compiles but fails with MatchException
-
- Resolved
-