Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8297118 Change IncompatibleClassChangeError to MatchException for exhaustive switch statements and switch expressions
  3. JDK-8297826

Release Note: An Exhaustive Switch over an Enum Class Should Throw `MatchException` Rather Than `IncompatibleClassChangeError` If No Switch Label Applies at Runtime

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Delivered
    • Icon: P4 P4
    • 20
    • 20
    • tools

      In this release, when preview features are enabled with `--enable-preview`, a
      `switch` expression over an enum type will throw a `MatchException` rather than
      an `IncompatibleClassChangeError` should the selector expression yield an
      unexpected enum constant value. This can only happen if the enum class has been
      changed by adding a new enum constant _after_ compilation of the `switch`.

      This change is required to unify the treatment of erroneous exhaustive switches
      introduced by enhancing `switch` with pattern labels.

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: