eclipse-jdt / eclipse-jdt/eclipse.jdt.core
[Switch-Expression] Bad code generation for switch expression inside enum constructor results in ExceptionInInitializerError
Open
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
The following program when compiled and run on master results in `ExceptionInInitializerError`:
```
public enum X {
ONE;
X() {
System.out.println(switch(this) {
default -> this;
});
}
public static void main(String [] args) {
X x = ONE;
System.out.println(x);
}
}
```
When run we get:
```
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.NullPointerException: Cannot read the array length because "" is null
at X.values(X.java:1)
at X.$SWITCH_TABLE$X(X.java:1)
at X.(X.java:4)
at X.(X.java:2)
```
Contributor guide
Assessment
This issue has not been assessed yet.