RFR: 8276836: Error in javac caused by switch expression without result expressions: Internal error: stack sim error
Guoxiong Li
gli at openjdk.java.net
Wed Dec 1 17:04:24 UTC 2021
On Wed, 1 Dec 2021 16:37:36 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
>> @lahodaj When I write the tests, I find that my patch fails at the test `4 + switch () {...} + switch () {...}`.
>>
>> When the compiler handles the first switch expression, it pops the stack element so that the stack becomes empty. When the compiler handles the second switch expression, it pops the stack element just like the first one. But the stack is empty and an ArrayOutOfBoundException will be reported.
>>
>> My current patch can't solve the issue. I will continue to find a better way to fix this bug. And the patch should be targeted to JDK19 because it seems not easy to solve it.
>
> Thanks @lgxbslgx, yes, I think this will be fairly complex, unfortunately. One more example (which does not include binary operators):
>
> public class M {
> private void m(int i, int j) {
> m(0, switch (j) { default: if (true) throw new RuntimeException(); yield 0;} );
> }
> }
>
>
> Regarding disabling the assertion, OK, maybe that was too much. But we may have to do something more general than only a tweak for binary operators, unfortunately.
@lahodaj would you like to take over this issue so that it can be solved as soon as possible (maybe JDK18)? I am glad to hand over it to you which can push the work.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6350
More information about the compiler-dev
mailing list