eclipse-jdt / eclipse.jdt.core

Eclipse Public License 2.0
138 stars 104 forks source link

[Switch Expression] Internal compiler error: java.util.EmptyStackException with switch expressions and exception handling #2373

Closed srikanth-sankaran closed 1 week ago

srikanth-sankaran commented 3 weeks ago

While using Java 22 preview feature "statements before super", ECJ runs into a runtime error.

Code:

interface I {
    void foo();
}

public class X {
    public static boolean b;

    static class Y {
        boolean b = true;
    }

    X() {
    }

    X(boolean b) {
        I l = () -> {
            X.b = new Y() {
                public boolean b() {
                    return this.b;
                }
            }.b();
            System.out.println(switch (42) {
            default -> {
                try {
                    yield 42;
                } finally {

                }
            }
            });
        };
        l.foo();
        super();
    }

    public static void main(String argv[]) {
        new X(true);
        System.out.println(X.b);
    }
}
srikanth-sankaran commented 3 weeks ago

https://github.com/eclipse-jdt/eclipse.jdt.core/pull/2354/ disables the test org.eclipse.jdt.core.tests.compiler.regression.SuperAfterStatementsTest._test037() - after fixing this issue, please reenable that. Thanks!