Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8233653

Reduce "exception is never thrown in body of corresponding try statement" Error to a Warning

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 13
    • tools
    • None
    • generic
    • generic

      per the discussion begun in https://mail.openjdk.java.net/pipermail/jdk-dev/2019-October/003480.html this change removes the following JLS rule from section 11.2.3:

           "It is a compile-time error if a catch clause can catch checked exception class E1
            and it is not the case that the try block corresponding to the
      catch clause can
            throw a checked exception class that is a subclass or superclass of
      E1, unless E1
            is Exception or a superclass of Exception."

      and converting the javac error message for this condition to a warning.

      The necessary patch required for this change is brief and will be posted as a webrev or PR once I remember how to do that again. ;-)

            mduigou Mike Duigou
            mduigou Mike Duigou
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: