--- old/src/share/classes/sun/nio/ch/FileChannelImpl.java 2012-11-02 19:24:32.000000000 +0100 +++ new/src/share/classes/sun/nio/ch/FileChannelImpl.java 2012-11-02 19:24:32.000000000 +0100 @@ -34,6 +34,7 @@ import java.util.List; import java.security.AccessController; import sun.misc.Cleaner; +import sun.misc.IoTrace; import sun.security.action.GetPropertyAction; public class FileChannelImpl @@ -56,13 +57,16 @@ // Required to prevent finalization of creating stream (immutable) private final Object parent; + // The path of the referenced file (null if there is no file) + private final String path; + // Thread-safe set of IDs of native threads, for signalling private final NativeThreadSet threads = new NativeThreadSet(2); // Lock for operations involving position and size private final Object positionLock = new Object(); - private FileChannelImpl(FileDescriptor fd, boolean readable, + private FileChannelImpl(FileDescriptor fd, String path, boolean readable, boolean writable, boolean append, Object parent) { this.fd = fd; @@ -70,23 +74,24 @@ this.writable = writable; this.append = append; this.parent = parent; + this.path = path; this.nd = new FileDispatcherImpl(append); } // Used by FileInputStream.getChannel() and RandomAccessFile.getChannel() - public static FileChannel open(FileDescriptor fd, + public static FileChannel open(FileDescriptor fd, String path, boolean readable, boolean writable, Object parent) { - return new FileChannelImpl(fd, readable, writable, false, parent); + return new FileChannelImpl(fd, path, readable, writable, false, parent); } // Used by FileOutputStream.getChannel - public static FileChannel open(FileDescriptor fd, + public static FileChannel open(FileDescriptor fd, String path, boolean readable, boolean writable, boolean append, Object parent) { - return new FileChannelImpl(fd, readable, writable, append, parent); + return new FileChannelImpl(fd, path, readable, writable, append, parent); } private void ensureOpen() throws IOException { @@ -134,6 +139,7 @@ synchronized (positionLock) { int n = 0; int ti = -1; + Object traceHandle = IoTrace.fileReadBegin(path); try { begin(); ti = threads.add(); @@ -146,6 +152,7 @@ } finally { threads.remove(ti); end(n > 0); + IoTrace.fileReadEnd(traceHandle, IOStatus.normalize(n)); assert IOStatus.check(n); } } @@ -162,6 +169,7 @@ synchronized (positionLock) { long n = 0; int ti = -1; + Object traceHandle = IoTrace.fileReadBegin(path); try { begin(); ti = threads.add(); @@ -174,6 +182,7 @@ } finally { threads.remove(ti); end(n > 0); + IoTrace.fileReadEnd(traceHandle, IOStatus.normalize(n)); assert IOStatus.check(n); } } @@ -186,6 +195,7 @@ synchronized (positionLock) { int n = 0; int ti = -1; + Object traceHandle = IoTrace.fileWriteBegin(path); try { begin(); ti = threads.add(); @@ -198,6 +208,7 @@ } finally { threads.remove(ti); end(n > 0); + IoTrace.fileWriteEnd(traceHandle, IOStatus.normalize(n)); assert IOStatus.check(n); } } @@ -214,6 +225,7 @@ synchronized (positionLock) { long n = 0; int ti = -1; + Object traceHandle = IoTrace.fileWriteBegin(path); try { begin(); ti = threads.add(); @@ -226,6 +238,7 @@ } finally { threads.remove(ti); end(n > 0); + IoTrace.fileWriteEnd(traceHandle, IOStatus.normalize(n)); assert IOStatus.check(n); } } @@ -665,6 +678,7 @@ ensureOpen(); int n = 0; int ti = -1; + Object traceHandle = IoTrace.fileReadBegin(path); try { begin(); ti = threads.add(); @@ -677,6 +691,7 @@ } finally { threads.remove(ti); end(n > 0); + IoTrace.fileReadEnd(traceHandle, IOStatus.normalize(n)); assert IOStatus.check(n); } } @@ -691,6 +706,7 @@ ensureOpen(); int n = 0; int ti = -1; + Object traceHandle = IoTrace.fileWriteBegin(path); try { begin(); ti = threads.add(); @@ -703,6 +719,7 @@ } finally { threads.remove(ti); end(n > 0); + IoTrace.fileWriteEnd(traceHandle, IOStatus.normalize(n)); assert IOStatus.check(n); } }