The file is java.nio.channels.SocketChannel.java
. JDK 7u45. The excerpt is:
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;
}
How does the compiler let passed that code? The signature declares IOException
, but the method's body catches Throwable
and retrows it. What don't I understand?