The error above is generated by the compiler in the PR https://github.com/eclipse-jdt/eclipse.jdt.core/pull/2449 but that PR doesn't build yet because it is finding inconsistencies/anomalies against itself and so the PR build will fail 😀 😀 😀
Here is an isolated test case where we mess up the operand stack:
import java.util.HashMap;
import java.util.Map;
public class X {
private static Map<String, Long> getLevelMapTable() {
Map<String, Long> t = new HashMap<>();
t.put(null, 0l);
return null;
}
}
How can we ascertain that we do indeed mess up the operand stack ? Simply insert an exception handling switch expression into the code above as in and compile with 3.29/3.30/3.31 and run it to see the verify error!
import java.util.HashMap;
import java.util.Map;
public class X {
static void foo(long l) {
}
private static Map<String, Long> getLevelMapTable() {
Map<String, Long> t = new HashMap<>();
t.put(null, 0l);
System.out.println(switch (42) {
default -> {
try {
yield 42;
} finally {
}
}
});
return null;
}
public static void main(String[] args) {
getLevelMapTable();
}
}
Compiling and running this program on 4.29 results in:
Error: Unable to initialize main class X
Caused by: java.lang.VerifyError: Operand stack underflow
Exception Details:
Location:
X.getLevelMapTable()Ljava/util/Map; @24: astore_2
Reason:
Attempt to pop empty stack.
The error above is generated by the compiler in the PR https://github.com/eclipse-jdt/eclipse.jdt.core/pull/2449 but that PR doesn't build yet because it is finding inconsistencies/anomalies against itself and so the PR build will fail 😀 😀 😀
Here is an isolated test case where we mess up the operand stack:
How can we ascertain that we do indeed mess up the operand stack ? Simply insert an exception handling switch expression into the code above as in and compile with 3.29/3.30/3.31 and run it to see the verify error!
Compiling and running this program on 4.29 results in: