-
Enhancement
-
Resolution: Fixed
-
P2
-
7
-
b94
-
unknown
-
generic
-
Verified
*) Catching multiple exception types: A single catch clause can now catch
more than one exception types, enabling a series of otherwise identical
catch clauses to be written as a single catch clause.
*) Improved checking for rethrown exceptions: Previously, rethrowing an
exception was treated as throwing the type of the catch parameter. Now,
when a catch parameter is declared final, rethrowing the exception is known
statically to throw only those checked exception types that were thrown in
the try block, are a subtype of the catch parameter type, and not caught in
preceding catch clauses.
EXAMPLE (multicatch):
before:
try {
doWork(file);
} catch (IOException ex) {
logger.log(ex);
} catch (SQLException ex) {
logger.log(ex);
}
after:
try {
doWork(file);
} catch (final IOException|SQLException ex) {
logger.log(ex);
}
EXAMPLE (rethrow)
before
void m() throws IOException, SQLException {
try {
doWork(file);
} catch (IOException) {
logger.log(ex);
} catch (SQLException ex) {
logger.log(ex);
throw ex; //rethrows IOException,SQLException
}
}
after:
void m() throws SQLException {
try {
doWork(file);
} catch (IOException) {
logger.log(ex);
} catch (final SQLException ex) {
logger.log(ex);
throw ex; //rethrows SQLException
}
}
- relates to
-
JDK-7011920 Project Coin: Sync with JSR 334 EDR
-
- Closed
-
-
JDK-6949587 rename "DisjointType" to "DisjunctType"
-
- Closed
-
-
JDK-6993963 Project Coin: Use precise exception analysis for effectively final catch parameters
-
- Closed
-
-
JDK-4432337 Catching multiple exceptions simultaneously
-
- Closed
-
-
JDK-7190387 multi-catch incorrectly exemplified as sequence of uni-catch
-
- Closed
-
-
JDK-8289975 Multi-catch leads to IllegalAccessError when least-upper-bound is inaccessible
-
- Open
-
-
JDK-8264696 Multi-catch clause causes compiler exception because it uses the package-private supertype
-
- Closed
-
-
JDK-8013163 Convert 4 tools multicatch tests to jtreg format
-
- Closed
-