Integrated: 8315735: VerifyError when switch statement used with synchronized block
Jan Lahoda
jlahoda at openjdk.org
Thu Sep 7 11:11:55 UTC 2023
On Wed, 6 Sep 2023 08:29:40 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.)
This pull request has now been integrated.
Changeset: 726c9c97
Author: Jan Lahoda <jlahoda at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/726c9c977dbaab75a2df4a931e3414ccabb7db44
Stats: 74 lines in 2 files changed: 69 ins; 0 del; 5 mod
8315735: VerifyError when switch statement used with synchronized block
Reviewed-by: vromero
-------------
PR: https://git.openjdk.org/jdk/pull/15584
More information about the compiler-dev
mailing list