FileDescriptor.java: Initialize fd to -1.
authorJeff Sturm <jeff.sturm@commerceone.com>
Tue, 26 Dec 2000 00:24:01 +0000 (00:24 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Tue, 26 Dec 2000 00:24:01 +0000 (00:24 +0000)
2000-12-24  Jeff Sturm  <jeff.sturm@commerceone.com>

* java/io/FileDescriptor.java: Initialize fd to -1.
Remove default constructor.

From-SVN: r38485

libjava/ChangeLog
libjava/java/io/FileDescriptor.java

index 14caf093fe189c45d03e49101351d15db3068556..0fbd6b92032674732d43139e1cb6d63cce50bddc 100644 (file)
@@ -1,3 +1,8 @@
+2000-12-24  Jeff Sturm  <jeff.sturm@commerceone.com>
+
+       * java/io/FileDescriptor.java: Initialize fd to -1.
+       Remove default constructor.
+
 2000-12-23  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * java/lang/mprec.h: Change C9X reference to refer to C99.
index 51c6fd6c5b1382d1a6c366fcc4872557f3972eca..493f14cf280731580a56b7f7c970ef4ec3970c81 100644 (file)
@@ -49,11 +49,6 @@ public final class FileDescriptor
     fd = open (path, mode);
   }
 
-  public FileDescriptor ()
-  {
-    fd = -1;
-  }
-
   native int open (String path, int mode) throws FileNotFoundException;
   native void write (int b) throws IOException;
   native void write (byte[] b, int offset, int len)
@@ -84,6 +79,10 @@ public final class FileDescriptor
     fd = desc;
   }
 
-  // System's notion of file descriptor.
-  private int fd;
+  // System's notion of file descriptor.  It might seem redundant to
+  // initialize this given that it is reassigned in the constructors.
+  // However, this is necessary because if open() throws an exception
+  // we want to make sure this has the value -1.  This is the most
+  // efficient way to accomplish that.
+  private int fd = -1;
 }