--- old/src/share/classes/java/io/FileInputStream.java 2012-11-02 19:24:23.000000000 +0100 +++ new/src/share/classes/java/io/FileInputStream.java 2012-11-02 19:24:22.000000000 +0100 @@ -27,6 +27,7 @@ import java.nio.channels.FileChannel; import sun.nio.ch.FileChannelImpl; +import sun.misc.IoTrace; /** @@ -51,6 +52,9 @@ /* File Descriptor - handle to the open file */ private final FileDescriptor fd; + /* The path of the referenced file (null if there is no file) */ + private final String path; + private FileChannel channel = null; private final Object closeLock = new Object(); @@ -125,6 +129,7 @@ } fd = new FileDescriptor(); fd.attach(this); + this.path = name; open(name); } @@ -161,6 +166,7 @@ security.checkRead(fdObj); } fd = fdObj; + path = null; /* * FileDescriptor is being shared by streams. @@ -183,7 +189,14 @@ * file is reached. * @exception IOException if an I/O error occurs. */ - public native int read() throws IOException; + public int read() throws IOException { + Object traceHandle = IoTrace.fileReadBegin(path); + int b = read0(); + IoTrace.fileReadEnd(traceHandle, b == -1 ? -1 : 1); + return b; + } + + private native int read0() throws IOException; /** * Reads a subarray as a sequence of bytes. @@ -206,7 +219,10 @@ * @exception IOException if an I/O error occurs. */ public int read(byte b[]) throws IOException { - return readBytes(b, 0, b.length); + Object traceHandle = IoTrace.fileReadBegin(path); + int bytesRead = readBytes(b, 0, b.length); + IoTrace.fileReadEnd(traceHandle, bytesRead); + return bytesRead; } /** @@ -228,7 +244,10 @@ * @exception IOException if an I/O error occurs. */ public int read(byte b[], int off, int len) throws IOException { - return readBytes(b, off, len); + Object traceHandle = IoTrace.fileReadBegin(path); + int bytesRead = readBytes(b, off, len); + IoTrace.fileReadEnd(traceHandle, bytesRead); + return bytesRead; } /** @@ -339,7 +358,7 @@ public FileChannel getChannel() { synchronized (this) { if (channel == null) { - channel = FileChannelImpl.open(fd, true, false, this); + channel = FileChannelImpl.open(fd, path, true, false, this); } return channel; }