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

Jan Lahoda jlahoda at openjdk.org
Wed Sep 6 20:35:18 UTC 2023


> 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:

  Improving readability by improving naming.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/15584/files
  - new: https://git.openjdk.org/jdk/pull/15584/files/26e29fe0..b1a04495

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=15584&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15584&range=01-02

  Stats: 6 lines in 1 file changed: 3 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/15584.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15584/head:pull/15584

PR: https://git.openjdk.org/jdk/pull/15584


More information about the compiler-dev mailing list