RFR: 8304694: Runtime exception thrown when break stmt is missing

Jan Lahoda jlahoda at openjdk.org
Wed Mar 22 16:26:44 UTC 2023


For code like this:

    public static int runFallThrough(R6 r) {
        switch (r) {
            case R6(var v1, var v2) when v1 != 0: return 0;
            case R6(var v1, var v2):
        }
        return 1;
    }


The execution falls through from the last case not outside the switch, but inside the fallback default case (that throws).

The current code is injecting breaks, but only for rule cases, and this situation where the last case needs a break is not handled. To simplify the code, it is now proposed to inject breaks at the beginning of the processing (rather than during processing/at the end) to all necessary cases.

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

Commit messages:
 - 8304694: Runtime exception thrown when break stmt is missing

Changes: https://git.openjdk.org/jdk/pull/13146/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13146&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8304694
  Stats: 21 lines in 2 files changed: 15 ins; 2 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/13146.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13146/head:pull/13146

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


More information about the compiler-dev mailing list