【发布时间】:2013-11-17 23:30:57
【问题描述】:
文件是java.nio.channels.SocketChannel.java。 JDK 7u45。摘录如下:
public static SocketChannel open(SocketAddress remote)
throws IOException
{
SocketChannel sc = open();
try {
sc.connect(remote);
} catch (Throwable x) {
try {
sc.close();
} catch (Throwable suppressed) {
x.addSuppressed(suppressed);
}
throw x;
}
assert sc.isConnected();
return sc;
}
编译器如何让该代码通过?签名声明了 IOException,但方法的主体捕获了 Throwable 并追溯它。什么不明白?
【问题讨论】:
标签: java exception java-7 checked-exceptions