--- old/src/share/classes/java/io/RandomAccessFile.java 2012-11-13 10:47:52.000000000 +0100 +++ new/src/share/classes/java/io/RandomAccessFile.java 2012-11-13 10:47:52.000000000 +0100 @@ -27,6 +27,8 @@ import java.nio.channels.FileChannel; import sun.nio.ch.FileChannelImpl; +import sun.misc.IoTrace; +import sun.misc.IoTraceContext; /** @@ -61,6 +63,7 @@ private FileDescriptor fd; private FileChannel channel = null; private boolean rw; + private final String path; private Object closeLock = new Object(); private volatile boolean closed = false; @@ -230,6 +233,7 @@ } fd = new FileDescriptor(); fd.attach(this); + this.path = name; open(name, imode); } @@ -269,7 +273,7 @@ public final FileChannel getChannel() { synchronized (this) { if (channel == null) { - channel = FileChannelImpl.open(fd, true, rw, this); + channel = FileChannelImpl.open(fd, path, true, rw, this); } return channel; } @@ -306,7 +310,18 @@ * @exception IOException if an I/O error occurs. Not thrown if * end-of-file has been reached. */ - public native int read() throws IOException; + public int read() throws IOException { + IoTraceContext traceContext = IoTrace.fileReadBegin(path); + int v = 0; + try { + v = read0(); + } finally { + IoTrace.fileReadEnd(traceContext, v == -1 ? 0 : 1); + } + return v; + } + + private native int read0() throws IOException; /** * Reads a sub array as a sequence of bytes. @@ -315,7 +330,18 @@ * @param len the number of bytes to read. * @exception IOException If an I/O error has occurred. */ - private native int readBytes(byte b[], int off, int len) throws IOException; + private int readBytes(byte b[], int off, int len) throws IOException { + IoTraceContext traceContext = IoTrace.fileReadBegin(path); + int v = 0; + try { + v = readBytes0(b, off, len); + } finally { + IoTrace.fileReadEnd(traceContext, v); + } + return v; + } + + private native int readBytes0(byte b[], int off, int len) throws IOException; /** * Reads up to {@code len} bytes of data from this file into an @@ -454,17 +480,38 @@ * @param b the {@code byte} to be written. * @exception IOException if an I/O error occurs. */ - public native void write(int b) throws IOException; + public void write(int b) throws IOException { + IoTraceContext traceContext = IoTrace.fileWriteBegin(path); + int v = 0; + try { + write0(b); + v = 1; + } finally { + IoTrace.fileWriteEnd(traceContext, v); + } + } + + private native void write0(int b) throws IOException; /** * Writes a sub array as a sequence of bytes. * @param b the data to be written - * @param off the start offset in the data * @param len the number of bytes that are written * @exception IOException If an I/O error has occurred. */ - private native void writeBytes(byte b[], int off, int len) throws IOException; + private void writeBytes(byte b[], int off, int len) throws IOException { + IoTraceContext traceContext = IoTrace.fileWriteBegin(path); + int v = 0; + try { + writeBytes0(b, off, len); + v = len; + } finally { + IoTrace.fileWriteEnd(traceContext, v); + } + } + + private native void writeBytes0(byte b[], int off, int len) throws IOException; /** * Writes {@code b.length} bytes from the specified byte array