eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
141 stars 107 forks source link

[Switch-expressions] Internal inconsistency warning at compile time and verify error at runtime #2453

Closed srikanth-sankaran closed 2 weeks ago

srikanth-sankaran commented 2 weeks ago

Code:

public class X {
    public static void main(String[] args) {
        System.out.println(double.class);
        System.out.println(switch (42) {
        default -> {
            try {
                yield 42;
            } finally {

            }
        }
        });
    }
}

On master we get a warning: Internal inconsistency: Inappropriate operand stack size encountered during translation and when the compiled program is run we get: java.lang.VerifyError: Operand stack underflow

On 4.29/4.30/4.31, failure mode is different, ECJ crashes with Internal compiler error: java.lang.NullPointerException: Cannot read field "id" because "typeBinding" is null at org.eclipse.jdt.internal.compiler.codegen.CodeStream.popInvokeTypeBinding(CodeStream.java:4716)

srikanth-sankaran commented 2 weeks ago

Problem uncovered with the enhanced sanity checks at https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2450