Closeable and Socket, ZipFile

Iris Garcia iag at ribbit.SFBay.Sun.COM
Fri Jul 6 19:00:59 UTC 2007


> 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 interfance. 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.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: 
    6499348: socket classes should implement
    - fixed in jdk7, b06

    4926319: java.util.Scanner needs a close method
    - fixed in jdk5.0-beta (b26)
    6389768: ZipFile should implement
    - currently unresolved RFE


More information about the core-libs-dev mailing list