--- old/src/share/classes/java/io/FileOutputStream.java 2012-11-13 10:47:50.000000000 +0100 +++ new/src/share/classes/java/io/FileOutputStream.java 2012-11-13 10:47:49.000000000 +0100 @@ -27,6 +27,8 @@ import java.nio.channels.FileChannel; import sun.nio.ch.FileChannelImpl; +import sun.misc.IoTrace; +import sun.misc.IoTraceContext; /** @@ -58,6 +60,11 @@ private final FileDescriptor fd; /** + * The path of the referenced file (null if the stream is created with a file descriptor) + */ + private final String path; + + /** * True if the file is opened for append. */ private final boolean append; @@ -199,7 +206,7 @@ this.fd = new FileDescriptor(); fd.attach(this); this.append = append; - + this.path = name; open(name, append); } @@ -235,6 +242,7 @@ security.checkWrite(fdObj); } this.fd = fdObj; + this.path = null; this.append = false; fd.attach(this); @@ -265,7 +273,14 @@ * @exception IOException if an I/O error occurs. */ public void write(int b) throws IOException { - write(b, append); + IoTraceContext traceContext = IoTrace.fileWriteBegin(path); + int bytesWritten = 0; + try { + write(b, append); + bytesWritten = 1; + } finally { + IoTrace.fileWriteEnd(traceContext, bytesWritten); + } } /** @@ -288,7 +303,14 @@ * @exception IOException if an I/O error occurs. */ public void write(byte b[]) throws IOException { - writeBytes(b, 0, b.length, append); + IoTraceContext traceContext = IoTrace.fileWriteBegin(path); + int bytesWritten = 0; + try { + writeBytes(b, 0, b.length, append); + bytesWritten = b.length; + } finally { + IoTrace.fileWriteEnd(traceContext, bytesWritten); + } } /** @@ -301,7 +323,14 @@ * @exception IOException if an I/O error occurs. */ public void write(byte b[], int off, int len) throws IOException { - writeBytes(b, off, len, append); + IoTraceContext traceContext = IoTrace.fileWriteBegin(path); + int bytesWritten = 0; + try { + writeBytes(b, off, len, append); + bytesWritten = len; + } finally { + IoTrace.fileWriteEnd(traceContext, bytesWritten); + } } /** @@ -373,7 +402,7 @@ public FileChannel getChannel() { synchronized (this) { if (channel == null) { - channel = FileChannelImpl.open(fd, false, true, append, this); + channel = FileChannelImpl.open(fd, path, false, true, append, this); } return channel; }