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

Details

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

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: