equal
deleted
inserted
replaced
46 */ |
46 */ |
47 public |
47 public |
48 class FileInputStream extends InputStream |
48 class FileInputStream extends InputStream |
49 { |
49 { |
50 /* File Descriptor - handle to the open file */ |
50 /* File Descriptor - handle to the open file */ |
51 private FileDescriptor fd; |
51 private final FileDescriptor fd; |
52 |
52 |
53 private FileChannel channel = null; |
53 private FileChannel channel = null; |
54 |
54 |
55 private Object closeLock = new Object(); |
55 private final Object closeLock = new Object(); |
56 private volatile boolean closed = false; |
56 private volatile boolean closed = false; |
57 |
57 |
58 private static ThreadLocal<Boolean> runningFinalize = |
58 private static final ThreadLocal<Boolean> runningFinalize = |
59 new ThreadLocal<Boolean>(); |
59 new ThreadLocal<Boolean>(); |
60 |
60 |
61 private static boolean isRunningFinalize() { |
61 private static boolean isRunningFinalize() { |
62 Boolean val; |
62 Boolean val; |
63 if ((val = runningFinalize.get()) != null) |
63 if ((val = runningFinalize.get()) != null) |
64 return val.booleanValue(); |
64 return val.booleanValue(); |
149 * <p> |
149 * <p> |
150 * If <code>fdObj</code> is null then a <code>NullPointerException</code> |
150 * If <code>fdObj</code> is null then a <code>NullPointerException</code> |
151 * is thrown. |
151 * is thrown. |
152 * <p> |
152 * <p> |
153 * This constructor does not throw an exception if <code>fdObj</code> |
153 * This constructor does not throw an exception if <code>fdObj</code> |
154 * is {link java.io.FileDescriptor#valid() invalid}. |
154 * is {@link java.io.FileDescriptor#valid() invalid}. |
155 * However, if the methods are invoked on the resulting stream to attempt |
155 * However, if the methods are invoked on the resulting stream to attempt |
156 * I/O on the stream, an <code>IOException</code> is thrown. |
156 * I/O on the stream, an <code>IOException</code> is thrown. |
157 * |
157 * |
158 * @param fdObj the file descriptor to be opened for reading. |
158 * @param fdObj the file descriptor to be opened for reading. |
159 * @throws SecurityException if a security manager exists and its |
159 * @throws SecurityException if a security manager exists and its |
387 * |
387 * |
388 * @exception IOException if an I/O error occurs. |
388 * @exception IOException if an I/O error occurs. |
389 * @see java.io.FileInputStream#close() |
389 * @see java.io.FileInputStream#close() |
390 */ |
390 */ |
391 protected void finalize() throws IOException { |
391 protected void finalize() throws IOException { |
392 if ((fd != null) && (fd != fd.in)) { |
392 if ((fd != null) && (fd != FileDescriptor.in)) { |
393 |
393 |
394 /* |
394 /* |
395 * Finalizer should not release the FileDescriptor if another |
395 * Finalizer should not release the FileDescriptor if another |
396 * stream is still using it. If the user directly invokes |
396 * stream is still using it. If the user directly invokes |
397 * close() then the FileDescriptor is also released. |
397 * close() then the FileDescriptor is also released. |