[PATCH 1/3] RFC: Adding Closeable to various JDK classes

David M. Lloyd david.lloyd at redhat.com
Thu May 1 15:08:42 UTC 2008


Add Closeable to core I/O classes and interfaces.  This one is a no-brainer 
- I hope. ;-)

Included is java.util.zip.ZipFile, since that class has a close method 
which exactly matches the Closeable interface specification.

- DML

--

diff -r 92ea0ac77d2f src/share/classes/java/io/ObjectInput.java
--- a/src/share/classes/java/io/ObjectInput.java	Tue Apr 22 18:58:40 2008 +0200
+++ b/src/share/classes/java/io/ObjectInput.java	Thu May 01 09:58:43 2008 -0500
@@ -36,7 +36,7 @@ package java.io;
   * @see java.io.ObjectInputStream
   * @since   JDK1.1
   */
-public interface ObjectInput extends DataInput {
+public interface ObjectInput extends DataInput, Closeable {
      /**
       * Read and return an object. The class that implements this interface
       * defines where the object is "read" from.
diff -r 92ea0ac77d2f src/share/classes/java/io/ObjectOutput.java
--- a/src/share/classes/java/io/ObjectOutput.java	Tue Apr 22 18:58:40 2008 
+0200
+++ b/src/share/classes/java/io/ObjectOutput.java	Thu May 01 09:58:43 2008 
-0500
@@ -36,7 +36,7 @@ package java.io;
   * @see java.io.ObjectInputStream
   * @since   JDK1.1
   */
-public interface ObjectOutput extends DataOutput {
+public interface ObjectOutput extends DataOutput, Flushable, Closeable {
      /**
       * Write an object to the underlying storage or stream.  The
       * class that implements this interface defines how the object is
diff -r 92ea0ac77d2f src/share/classes/java/nio/channels/Selector.java
--- a/src/share/classes/java/nio/channels/Selector.java	Tue Apr 22 18:58:40 
2008 +0200
+++ b/src/share/classes/java/nio/channels/Selector.java	Thu May 01 09:58:43 
2008 -0500
@@ -25,6 +25,7 @@

  package java.nio.channels;

+import java.io.Closeable;
  import java.io.IOException;
  import java.nio.channels.spi.SelectorProvider;
  import java.util.Set;
@@ -202,7 +203,7 @@ import java.util.Set;
   * @see SelectionKey
   */

-public abstract class Selector {
+public abstract class Selector implements Closeable {

      /**
       * Initializes a new instance of this class.
diff -r 92ea0ac77d2f src/share/classes/java/util/zip/ZipFile.java
--- a/src/share/classes/java/util/zip/ZipFile.java	Tue Apr 22 18:58:40 2008 
+0200
+++ b/src/share/classes/java/util/zip/ZipFile.java	Thu May 01 09:58:43 2008 
-0500
@@ -29,6 +29,7 @@ import java.io.IOException;
  import java.io.IOException;
  import java.io.EOFException;
  import java.io.File;
+import java.io.Closeable;
  import java.util.Vector;
  import java.util.Enumeration;
  import java.util.NoSuchElementException;
@@ -43,7 +44,7 @@ import java.util.NoSuchElementException;
   * @author      David Connelly
   */
  public
-class ZipFile implements ZipConstants {
+class ZipFile implements ZipConstants, Closeable {
      private long jzfile;  // address of jzfile data
      private String name;  // zip file name
      private int total;    // total number of entries




More information about the core-libs-dev mailing list