java.io.Closeable: Too late for a change?
I wonder whether it would be feasible to change the declaration of the interface java.io.Closeable (introduced in java 1.5) as follows:
<br /> public void close() throws IOException;<br />
<br /> public void close() throws Exception;<br />
The rationale behind this change is that there are many resource-related classes that would benefit from implementing Closeable, but cannot do so because their close methods do not throw IOException. (Prominent example: java.sql.Connection).
Please note that the change would not introduce incompatiblities with regards to the implementing classes or extending interfaces: they would still restrict their throws clause to a more specific Exception type.
The change would, however, cause a source incompatiblity with code actually using the interface java.io.Closeable and not catching java.lang.Exception. Such code would have to be refactored in order to be compilable. (Libraries using java.io.Closeable would not have to be re-compiled, though!)
What do you think?