JEP draft: Exception handling in switch (Preview)
Summary
Enhance the switch construct so that its block can handle exceptions thrown by the selector (the e in switch (e) ...). Alongside a previous enhancement to handle null selectors, this makes switch even more useful for pattern matching. This is a preview language feature.
Goals
Allow switch to perform case analysis over all the possible outcomes of evaluating the selector.
Streamline usage of libraries that make use of checked exceptions.
Improve readability by uniformly handling all outco...
Read more at openjdk.org