编译期间意外的异常处理

Pie*_*Bos 13 java exception-handling

我遇到了以下方法,令我惊讶的是编译得很好:

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;
    }

}
Run Code Online (Sandbox Code Playgroud)

为什么没有必要Exception被抓住?

Nan*_*ale 16

它是Java 7中添加的功能.请查看包含更多包含类型检查的Rethrowing异常

  • @Tobold - 我认为它很好地回答了它 (3认同)