编译期间意外的异常处理

时间:2014-02-20 12:22:51

标签: 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;
    }

}

为什么没有必要抓住Exception

1 个答案:

答案 0 :(得分:16)

这是Java 7中添加的功能。请查看Rethrowing Exceptions with More Inclusive Type Checking