RFR: 8315735: VerifyError when switch statement used with synchronized block [v2]

Vicente Romero vromero at openjdk.org
Wed Sep 6 20:04:40 UTC 2023


On Wed, 6 Sep 2023 18:58:19 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> Having code like:
>> 
>>     public static void main(String... args) {
>>         int i1 = 0 + switch (args.length) {
>>             default -> {
>>                 synchronized (args) {
>>                     yield 1;
>>                 }
>>             }
>>         };
>>     }
>> 
>> 
>> fails with a verification error at runtime. In the classfile, the synchronized block is basically a try-finally (which has an implicit "catch (any)" block), and so it needs the same handling as ordinary try statements.
>> 
>> (When there's a try statement inside a switch expression, the pre-existing stack is stored in local variables, and restored at return from the case. This is because catch clauses start with an empty stack.)
>
> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Reflecting review feedback.

looks good

-------------

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/15584#pullrequestreview-1614120200


More information about the compiler-dev mailing list