14

I encountered the following method, which to my surprise compiled just fine:

private String getControlMessageBlocking() throws ProtocolException,
        InterruptedException, IOException {
    try {
        // <Code that may throw any of the three listed exceptions>
        return controlMessage;
    } catch (Exception e) {
        throw e;
    }

}

Why isn't it necessary for the Exception to be caught?

Pieter Bos
  • 1,554
  • 1
  • 12
  • 20

1 Answers1

17

It is the feature added in Java 7. Have a look at Rethrowing Exceptions with More Inclusive Type Checking

Nandkumar Tekale
  • 16,024
  • 8
  • 58
  • 85