Hi,

I'd like to be able to substitute different subclasses (based on what OS
we're running on) for FileChannelImpl, so I'd like to change the public
constructor to a factory method.

Any objections/comments?

Regards,
Jeroen

2005-05-28  Jeroen Frijters  <[EMAIL PROTECTED]>

        * gnu/java/nio/channels/FileChannelImpl.java
        (FileChannelImpl()): Removed.
        (FileChannelImpl(File,int)): Made private.
        (create): New method.

        * java/io/FileInputStream.java,
        java/io/FileOutputStream.java,
        java/io/RandomAccessFile.java:
        Updated construction of FileChannelImpl instance.

        
Index: gnu/java/nio/channels/FileChannelImpl.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/nio/channels/FileChannelImpl.java,v
retrieving revision 1.12
diff -u -r1.12 FileChannelImpl.java
--- gnu/java/nio/channels/FileChannelImpl.java  3 May 2005 22:36:55 -0000       
1.12
+++ gnu/java/nio/channels/FileChannelImpl.java  28 May 2005 11:44:23 -0000
@@ -97,12 +97,17 @@
 
   private int mode;
 
-  public FileChannelImpl ()
+  /* Open a file.  MODE is a combination of the above mode flags. */
+  /* This is a static factory method, so that VM implementors can decide
+   * substitute subclasses of FileChannelImpl. */
+  public static FileChannelImpl create(File file, int mode)
+    throws FileNotFoundException
   {
+    return new FileChannelImpl(file, mode);
   }
 
-  /* Open a file.  MODE is a combination of the above mode flags. */
-  public FileChannelImpl (File file, int mode) throws FileNotFoundException
+  private FileChannelImpl(File file, int mode)
+    throws FileNotFoundException
   {
     final String path = file.getPath();
     fd = open (path, mode);
Index: java/io/FileInputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/FileInputStream.java,v
retrieving revision 1.32
diff -u -r1.32 FileInputStream.java
--- java/io/FileInputStream.java        29 Apr 2005 16:57:05 -0000      1.32
+++ java/io/FileInputStream.java        28 May 2005 11:44:32 -0000
@@ -107,7 +107,7 @@
     if (s != null)
       s.checkRead(file.getPath());
 
-    ch = new FileChannelImpl (file, FileChannelImpl.READ);
+    ch = FileChannelImpl.create(file, FileChannelImpl.READ);
   }
 
   /**
Index: java/io/FileOutputStream.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/FileOutputStream.java,v
retrieving revision 1.35
diff -u -r1.35 FileOutputStream.java
--- java/io/FileOutputStream.java       29 Apr 2005 16:57:05 -0000      1.35
+++ java/io/FileOutputStream.java       28 May 2005 11:44:33 -0000
@@ -155,7 +155,7 @@
     if (s != null)
       s.checkWrite(file.getPath());
 
-   ch = new FileChannelImpl (file, (append
+   ch = FileChannelImpl.create(file, (append
                                    ? FileChannelImpl.WRITE
                                    | FileChannelImpl.APPEND
                                    : FileChannelImpl.WRITE));
Index: java/io/RandomAccessFile.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/RandomAccessFile.java,v
retrieving revision 1.45
diff -u -r1.45 RandomAccessFile.java
--- java/io/RandomAccessFile.java       29 Apr 2005 16:57:05 -0000      1.45
+++ java/io/RandomAccessFile.java       28 May 2005 11:44:34 -0000
@@ -122,7 +122,7 @@
           s.checkWrite(fileName);
       }
 
-    ch = new FileChannelImpl (file, fdmode);
+    ch = FileChannelImpl.create(file, fdmode);
     fd = new FileDescriptor(ch);
     out = new DataOutputStream (new FileOutputStream (fd));
     in = new DataInputStream (new FileInputStream (fd));
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to