RFR: 8348410: Preview flag not checked during compilation resulting in runtime crash [v3]

Archie Cobbs acobbs at openjdk.org
Wed May 7 15:08:36 UTC 2025


> JEP 455 adds support for `switch`'ing on `long`, `float`, `double`, and `boolean`. Since this feature is still in preview, the `--enable-preview` flag is required. The compiler was properly checking that when the expressions had primitive type, but not when the expression a corresponding boxed type (i.e., `Long`, `Float`, `Double`, and `Boolean`). This resulted in `BootstrapMethodError` failures at runtime. This PR closes that loophole.

Archie Cobbs has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:

 - Merge branch 'master' into JDK-8348410
 - Address review of #23303
 - Merge branch 'master' into JDK-8348410
 - Fix typo in regression test @summary lines.
 - Check preview enabled for switch on boxed Booleam, Long, Float, or Double.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/23303/files
  - new: https://git.openjdk.org/jdk/pull/23303/files/72b7804b..0236793e

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

  Stats: 19822 lines in 538 files changed: 12621 ins; 4322 del; 2879 mod
  Patch: https://git.openjdk.org/jdk/pull/23303.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23303/head:pull/23303

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


More information about the compiler-dev mailing list