--- old/src/share/classes/java/util/zip/Deflater.java 2012-08-03 11:41:27.000000000 -0700 +++ new/src/share/classes/java/util/zip/Deflater.java 2012-08-03 11:41:26.000000000 -0700 @@ -79,6 +79,8 @@ private int level, strategy; private boolean setParams; private boolean finish, finished; + private long bytesRead; + private long bytesWritten; /** * Compression method for the deflate algorithm (the only one currently @@ -423,8 +425,13 @@ synchronized (zsRef) { ensureOpen(); if (flush == NO_FLUSH || flush == SYNC_FLUSH || - flush == FULL_FLUSH) - return deflateBytes(zsRef.address(), b, off, len, flush); + flush == FULL_FLUSH) { + int thisLen = this.len; + int n = deflateBytes(zsRef.address(), b, off, len, flush); + bytesWritten += n; + bytesRead += (thisLen - this.len); + return n; + } throw new IllegalArgumentException(); } } @@ -462,7 +469,7 @@ public long getBytesRead() { synchronized (zsRef) { ensureOpen(); - return getBytesRead(zsRef.address()); + return bytesRead; } } @@ -488,7 +495,7 @@ public long getBytesWritten() { synchronized (zsRef) { ensureOpen(); - return getBytesWritten(zsRef.address()); + return bytesWritten; } } @@ -503,6 +510,7 @@ finish = false; finished = false; off = len = 0; + bytesRead = bytesWritten = 0; } } @@ -543,8 +551,6 @@ private native int deflateBytes(long addr, byte[] b, int off, int len, int flush); private native static int getAdler(long addr); - private native static long getBytesRead(long addr); - private native static long getBytesWritten(long addr); private native static void reset(long addr); private native static void end(long addr); }