Closeable and Socket, ZipFile
Iris Garcia
iag at ribbit.SFBay.Sun.COM
Fri Jul 6 19:00:59 UTC 2007
Hi.
> Pascal S. de Kloe wrote:
> >
> > Socket, ServerSocket and ZipFile all have a close() method which closes
> > the respective streams so what's the problem?
>
> As I said, those classes do not implement the java.io.Closeable interfance.
java.io.Closeable was added semi-late into jdk5.0 to support
java.util.Formatter. In that same release it also became useful for
java.util.Scanner. At that time there was need (and to a certain
extent time) for us to identify those classes which closely interacted
with one of those two features (primarily classes in java.io java.nio,
and java.nio.channels), so that's all that we took care of.
Assuming they follow the specification, it would be perfectly
reasonable for any class to declare that they implement Closeable.
Here's the status for the specific classes mentioned:
java.net.Socket:
6499348: java.net socket classes should implement java.io.Closeable
- fixed in jdk7, b06
java.nio.SocketChannel:
4926319: java.util.Scanner needs a close method
- fixed in jdk5.0-beta (b26)
java.util.zip.ZipFile:
6389768: ZipFile should implement java.io.Closeable
- currently unresolved RFE
Thanks,
iris
More information about the core-libs-dev
mailing list