src/solaris/classes/java/io/FileDescriptor.java

Print this page
rev 10048 : 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
Reviewed-by:


  24  */
  25 
  26 package java.io;
  27 
  28 import java.util.ArrayList;
  29 import java.util.List;
  30 
  31 /**
  32  * Instances of the file descriptor class serve as an opaque handle
  33  * to the underlying machine-specific structure representing an open
  34  * file, an open socket, or another source or sink of bytes. The
  35  * main practical use for a file descriptor is to create a
  36  * <code>FileInputStream</code> or <code>FileOutputStream</code> to
  37  * contain it.
  38  * <p>
  39  * Applications should not create their own file descriptors.
  40  *
  41  * @author  Pavani Diwanji
  42  * @see     java.io.FileInputStream
  43  * @see     java.io.FileOutputStream
  44  * @since   JDK1.0
  45  */
  46 public final class FileDescriptor {
  47 
  48     private int fd;
  49 
  50     private Closeable parent;
  51     private List<Closeable> otherParents;
  52     private boolean closed;
  53 
  54     /**
  55      * Constructs an (invalid) FileDescriptor
  56      * object.
  57      */
  58     public /**/ FileDescriptor() {
  59         fd = -1;
  60     }
  61 
  62     private /* */ FileDescriptor(int fd) {
  63         this.fd = fd;
  64     }


 109      * system, sync will not return until all in-memory modified copies
 110      * of buffers associated with this FileDescriptor have been
 111      * written to the physical medium.
 112      *
 113      * sync is meant to be used by code that requires physical
 114      * storage (such as a file) to be in a known state  For
 115      * example, a class that provided a simple transaction facility
 116      * might use sync to ensure that all changes to a file caused
 117      * by a given transaction were recorded on a storage medium.
 118      *
 119      * sync only affects buffers downstream of this FileDescriptor.  If
 120      * any in-memory buffering is being done by the application (for
 121      * example, by a BufferedOutputStream object), those buffers must
 122      * be flushed into the FileDescriptor (for example, by invoking
 123      * OutputStream.flush) before that data will be affected by sync.
 124      *
 125      * @exception SyncFailedException
 126      *        Thrown when the buffers cannot be flushed,
 127      *        or because the system cannot guarantee that all the
 128      *        buffers have been synchronized with physical media.
 129      * @since     JDK1.1
 130      */
 131     public native void sync() throws SyncFailedException;
 132 
 133     /* This routine initializes JNI field offsets for the class */
 134     private static native void initIDs();
 135 
 136     static {
 137         initIDs();
 138     }
 139 
 140     // Set up JavaIOFileDescriptorAccess in SharedSecrets
 141     static {
 142         sun.misc.SharedSecrets.setJavaIOFileDescriptorAccess(
 143             new sun.misc.JavaIOFileDescriptorAccess() {
 144                 public void set(FileDescriptor obj, int fd) {
 145                     obj.fd = fd;
 146                 }
 147 
 148                 public int get(FileDescriptor obj) {
 149                     return obj.fd;




  24  */
  25 
  26 package java.io;
  27 
  28 import java.util.ArrayList;
  29 import java.util.List;
  30 
  31 /**
  32  * Instances of the file descriptor class serve as an opaque handle
  33  * to the underlying machine-specific structure representing an open
  34  * file, an open socket, or another source or sink of bytes. The
  35  * main practical use for a file descriptor is to create a
  36  * <code>FileInputStream</code> or <code>FileOutputStream</code> to
  37  * contain it.
  38  * <p>
  39  * Applications should not create their own file descriptors.
  40  *
  41  * @author  Pavani Diwanji
  42  * @see     java.io.FileInputStream
  43  * @see     java.io.FileOutputStream
  44  * @since   1.0
  45  */
  46 public final class FileDescriptor {
  47 
  48     private int fd;
  49 
  50     private Closeable parent;
  51     private List<Closeable> otherParents;
  52     private boolean closed;
  53 
  54     /**
  55      * Constructs an (invalid) FileDescriptor
  56      * object.
  57      */
  58     public /**/ FileDescriptor() {
  59         fd = -1;
  60     }
  61 
  62     private /* */ FileDescriptor(int fd) {
  63         this.fd = fd;
  64     }


 109      * system, sync will not return until all in-memory modified copies
 110      * of buffers associated with this FileDescriptor have been
 111      * written to the physical medium.
 112      *
 113      * sync is meant to be used by code that requires physical
 114      * storage (such as a file) to be in a known state  For
 115      * example, a class that provided a simple transaction facility
 116      * might use sync to ensure that all changes to a file caused
 117      * by a given transaction were recorded on a storage medium.
 118      *
 119      * sync only affects buffers downstream of this FileDescriptor.  If
 120      * any in-memory buffering is being done by the application (for
 121      * example, by a BufferedOutputStream object), those buffers must
 122      * be flushed into the FileDescriptor (for example, by invoking
 123      * OutputStream.flush) before that data will be affected by sync.
 124      *
 125      * @exception SyncFailedException
 126      *        Thrown when the buffers cannot be flushed,
 127      *        or because the system cannot guarantee that all the
 128      *        buffers have been synchronized with physical media.
 129      * @since     1.1
 130      */
 131     public native void sync() throws SyncFailedException;
 132 
 133     /* This routine initializes JNI field offsets for the class */
 134     private static native void initIDs();
 135 
 136     static {
 137         initIDs();
 138     }
 139 
 140     // Set up JavaIOFileDescriptorAccess in SharedSecrets
 141     static {
 142         sun.misc.SharedSecrets.setJavaIOFileDescriptorAccess(
 143             new sun.misc.JavaIOFileDescriptorAccess() {
 144                 public void set(FileDescriptor obj, int fd) {
 145                     obj.fd = fd;
 146                 }
 147 
 148                 public int get(FileDescriptor obj) {
 149                     return obj.fd;