Why Channel interface redefine close() method?

60 views Asked by At

The close() method has already defined in the Closeable interface, why Channel redefines it again?

package java.io;
import java.io.IOException;

public interface Closeable extends AutoCloseable {
    public void close() throws IOException;
}
package java.nio.channels;

import java.io.IOException;
import java.io.Closeable;

public interface Channel extends Closeable {

    public boolean isOpen();

    public void close() throws IOException;

}
1

There are 1 answers

0
Polygnome On BEST ANSWER

You have unfortunately not copied the most important parts - the JavaDoc.

The JavaDoc of Channel#close() clarifies quite a bit of the channel-specific details for this method, for example that subsequent operations throw ClosedChannelException, and how this method behaves when multiple threads are involved, especially blocking behavior.

Also, Channel predates Closeable (introduced in 1.4, Closeable in 1.5) and was retrofitted with that interface.