RFR: 8347291: Exhaustive switch over a generic sealed abstract class

Liam Miller-Cushon cushon at openjdk.org
Wed Mar 12 22:18:24 UTC 2025


This change avoids javac incorrectly reporting switches like the example in [JDK-8347291](https://bugs.openjdk.org/browse/JDK-8347291) as exhaustive.

As Jan noted in the bug it seems like the inference behaviour here may not be correct. If it was able to infer a type without crashing that would also avoid the bug.

However with the current inference behaviour, it's safer to assume that if inference crashes the subtype may need to be handled by the switch, instead of assuming that it doesn't.

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

Commit messages:
 - Merge remote-tracking branch 'origin/master' into JDK-8347291
 - 8347291: Exhaustive switch over a generic sealed abstract class

Changes: https://git.openjdk.org/jdk/pull/23286/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23286&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8347291
  Stats: 34 lines in 4 files changed: 30 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/23286.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23286/head:pull/23286

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


More information about the compiler-dev mailing list