10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 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 34 * open file, an open socket, or another source or sink of bytes. 35 * The main practical use for a file descriptor is to create a 36 * {@link FileInputStream} or {@link FileOutputStream} to contain it. 37 * 38 * <p>Applications should not create their own file descriptors. 39 * 40 * @author Pavani Diwanji 41 * @since 1.0 42 */ 43 public final class FileDescriptor { 44 45 private int fd; 46 47 private long handle; 48 49 private Closeable parent; 53 /** 54 * true, if file is opened for appending. 55 */ 56 private boolean append; 57 58 /** 59 * Constructs an (invalid) FileDescriptor 60 * object. 61 */ 62 public /**/ FileDescriptor() { 63 fd = -1; 64 handle = -1; 65 } 66 67 static { 68 initIDs(); 69 } 70 71 // Set up JavaIOFileDescriptorAccess in SharedSecrets 72 static { 73 sun.misc.SharedSecrets.setJavaIOFileDescriptorAccess( 74 new sun.misc.JavaIOFileDescriptorAccess() { 75 public void set(FileDescriptor obj, int fd) { 76 obj.fd = fd; 77 } 78 79 public int get(FileDescriptor obj) { 80 return obj.fd; 81 } 82 83 public void setAppend(FileDescriptor obj, boolean append) { 84 obj.append = append; 85 } 86 87 public boolean getAppend(FileDescriptor obj) { 88 return obj.append; 89 } 90 91 public void setHandle(FileDescriptor obj, long handle) { 92 obj.handle = handle; 93 } 94 | 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.io; 27 28 import java.util.ArrayList; 29 import java.util.List; 30 import jdk.internal.misc.JavaIOFileDescriptorAccess; 31 import jdk.internal.misc.SharedSecrets; 32 33 /** 34 * Instances of the file descriptor class serve as an opaque handle 35 * to the underlying machine-specific structure representing an 36 * open file, an open socket, or another source or sink of bytes. 37 * The main practical use for a file descriptor is to create a 38 * {@link FileInputStream} or {@link FileOutputStream} to contain it. 39 * 40 * <p>Applications should not create their own file descriptors. 41 * 42 * @author Pavani Diwanji 43 * @since 1.0 44 */ 45 public final class FileDescriptor { 46 47 private int fd; 48 49 private long handle; 50 51 private Closeable parent; 55 /** 56 * true, if file is opened for appending. 57 */ 58 private boolean append; 59 60 /** 61 * Constructs an (invalid) FileDescriptor 62 * object. 63 */ 64 public /**/ FileDescriptor() { 65 fd = -1; 66 handle = -1; 67 } 68 69 static { 70 initIDs(); 71 } 72 73 // Set up JavaIOFileDescriptorAccess in SharedSecrets 74 static { 75 SharedSecrets.setJavaIOFileDescriptorAccess( 76 new JavaIOFileDescriptorAccess() { 77 public void set(FileDescriptor obj, int fd) { 78 obj.fd = fd; 79 } 80 81 public int get(FileDescriptor obj) { 82 return obj.fd; 83 } 84 85 public void setAppend(FileDescriptor obj, boolean append) { 86 obj.append = append; 87 } 88 89 public boolean getAppend(FileDescriptor obj) { 90 return obj.append; 91 } 92 93 public void setHandle(FileDescriptor obj, long handle) { 94 obj.handle = handle; 95 } 96 |