提交 420617ce 编写于 作者: M martin

6631437: File{In,Out}putStream minor improvements to spec and stylistic improvements to code

Reviewed-by: alanb, iris
上级 c3da802e
...@@ -48,15 +48,15 @@ public ...@@ -48,15 +48,15 @@ public
class FileInputStream extends InputStream class FileInputStream extends InputStream
{ {
/* File Descriptor - handle to the open file */ /* File Descriptor - handle to the open file */
private FileDescriptor fd; private final FileDescriptor fd;
private FileChannel channel = null; private FileChannel channel = null;
private Object closeLock = new Object(); private final Object closeLock = new Object();
private volatile boolean closed = false; private volatile boolean closed = false;
private static ThreadLocal<Boolean> runningFinalize = private static final ThreadLocal<Boolean> runningFinalize =
new ThreadLocal<Boolean>(); new ThreadLocal<Boolean>();
private static boolean isRunningFinalize() { private static boolean isRunningFinalize() {
Boolean val; Boolean val;
...@@ -151,7 +151,7 @@ class FileInputStream extends InputStream ...@@ -151,7 +151,7 @@ class FileInputStream extends InputStream
* is thrown. * is thrown.
* <p> * <p>
* This constructor does not throw an exception if <code>fdObj</code> * This constructor does not throw an exception if <code>fdObj</code>
* is {link java.io.FileDescriptor#valid() invalid}. * is {@link java.io.FileDescriptor#valid() invalid}.
* However, if the methods are invoked on the resulting stream to attempt * However, if the methods are invoked on the resulting stream to attempt
* I/O on the stream, an <code>IOException</code> is thrown. * I/O on the stream, an <code>IOException</code> is thrown.
* *
...@@ -389,7 +389,7 @@ class FileInputStream extends InputStream ...@@ -389,7 +389,7 @@ class FileInputStream extends InputStream
* @see java.io.FileInputStream#close() * @see java.io.FileInputStream#close()
*/ */
protected void finalize() throws IOException { protected void finalize() throws IOException {
if ((fd != null) && (fd != fd.in)) { if ((fd != null) && (fd != FileDescriptor.in)) {
/* /*
* Finalizer should not release the FileDescriptor if another * Finalizer should not release the FileDescriptor if another
......
...@@ -52,20 +52,18 @@ public ...@@ -52,20 +52,18 @@ public
class FileOutputStream extends OutputStream class FileOutputStream extends OutputStream
{ {
/** /**
* The system dependent file descriptor. The value is * The system dependent file descriptor.
* 1 more than actual file descriptor. This means that
* the default value 0 indicates that the file is not open.
*/ */
private FileDescriptor fd; private final FileDescriptor fd;
private FileChannel channel= null; private FileChannel channel= null;
private boolean append = false; private boolean append = false;
private Object closeLock = new Object(); private final Object closeLock = new Object();
private volatile boolean closed = false; private volatile boolean closed = false;
private static ThreadLocal<Boolean> runningFinalize = private static final ThreadLocal<Boolean> runningFinalize =
new ThreadLocal<Boolean>(); new ThreadLocal<Boolean>();
private static boolean isRunningFinalize() { private static boolean isRunningFinalize() {
Boolean val; Boolean val;
...@@ -75,7 +73,7 @@ class FileOutputStream extends OutputStream ...@@ -75,7 +73,7 @@ class FileOutputStream extends OutputStream
} }
/** /**
* Creates an output file stream to write to the file with the * Creates a file output stream to write to the file with the
* specified name. A new <code>FileDescriptor</code> object is * specified name. A new <code>FileDescriptor</code> object is
* created to represent this file connection. * created to represent this file connection.
* <p> * <p>
...@@ -100,8 +98,8 @@ class FileOutputStream extends OutputStream ...@@ -100,8 +98,8 @@ class FileOutputStream extends OutputStream
} }
/** /**
* Creates an output file stream to write to the file with the specified * Creates a file output stream to write to the file with the specified
* <code>name</code>. If the second argument is <code>true</code>, then * name. If the second argument is <code>true</code>, then
* bytes will be written to the end of the file rather than the beginning. * bytes will be written to the end of the file rather than the beginning.
* A new <code>FileDescriptor</code> object is created to represent this * A new <code>FileDescriptor</code> object is created to represent this
* file connection. * file connection.
...@@ -211,7 +209,7 @@ class FileOutputStream extends OutputStream ...@@ -211,7 +209,7 @@ class FileOutputStream extends OutputStream
} }
/** /**
* Creates an output file stream to write to the specified file * Creates a file output stream to write to the specified file
* descriptor, which represents an existing connection to an actual * descriptor, which represents an existing connection to an actual
* file in the file system. * file in the file system.
* <p> * <p>
...@@ -223,7 +221,7 @@ class FileOutputStream extends OutputStream ...@@ -223,7 +221,7 @@ class FileOutputStream extends OutputStream
* is thrown. * is thrown.
* <p> * <p>
* This constructor does not throw an exception if <code>fdObj</code> * This constructor does not throw an exception if <code>fdObj</code>
* is {link java.io.FileDescriptor#valid() invalid}. * is {@link java.io.FileDescriptor#valid() invalid}.
* However, if the methods are invoked on the resulting stream to attempt * However, if the methods are invoked on the resulting stream to attempt
* I/O on the stream, an <code>IOException</code> is thrown. * I/O on the stream, an <code>IOException</code> is thrown.
* *
...@@ -408,7 +406,7 @@ class FileOutputStream extends OutputStream ...@@ -408,7 +406,7 @@ class FileOutputStream extends OutputStream
*/ */
protected void finalize() throws IOException { protected void finalize() throws IOException {
if (fd != null) { if (fd != null) {
if (fd == fd.out || fd == fd.err) { if (fd == FileDescriptor.out || fd == FileDescriptor.err) {
flush(); flush();
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册