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

missing warn about exception not thrown in try block if finally can't complete

XMLWordPrintable

    • hopper
    • generic
    • solaris_8
    • Verified

      The following program should not compile because the exception caught
      in the catch block cannot be thrown by the try block. javac 1.3 and
      later fails to diagnose this problem. This is a regression from previous
      versions of the compiler.

      class T {
          static class E extends Exception {}

          public void t() throws E {}

          void f() {
              try {
                  try {
                      t();
                  } finally {
                      return;
                  }
              } catch (E x) { // error: E can't be thrown in try block
              }
          }
      }

            gafter Neal Gafter (Inactive)
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: