# HG changeset patch # User sherman # Date 1481140406 28800 # Node ID 628321b5a236f8dd9b88b4bf71a761fb38d1db12 # Parent b9b966ca4a58bf1670ffc243ecae6b0646c807b9 8170831: ZipFile implementation no longer caches the last accessed entry/pos Reviewed-by: psandoz diff -r b9b966ca4a58 -r 628321b5a236 jdk/src/java.base/share/classes/java/util/zip/ZipFile.java --- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java Wed Nov 30 19:40:36 2016 -0800 +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java Wed Dec 07 11:53:26 2016 -0800 @@ -331,7 +331,9 @@ ZipFileInputStream in = null; synchronized (this) { ensureOpen(); - if (!zc.isUTF8() && (entry.flag & EFS) != 0) { + if (Objects.equals(lastEntryName, entry.name)) { + pos = lastEntryPos; + } else if (!zc.isUTF8() && (entry.flag & EFS) != 0) { pos = zsrc.getEntryPos(zc.getBytesUTF8(entry.name), false); } else { pos = zsrc.getEntryPos(zc.getBytes(entry.name), false); @@ -526,6 +528,9 @@ Spliterator.IMMUTABLE | Spliterator.NONNULL), false); } + private String lastEntryName; + private int lastEntryPos; + /* Checks ensureOpen() before invoke this method */ private ZipEntry getZipEntry(String name, byte[] bname, int pos) { byte[] cen = zsrc.cen; @@ -563,6 +568,8 @@ e.comment = zc.toString(cen, start, clen); } } + lastEntryName = e.name; + lastEntryPos = pos; return e; }