< prev index next >

src/java.base/share/classes/java/util/zip/ZipFile.java

Print this page
8200124: Various cleanups in jar/zip
Reviewed-by: sherman

*** 62,71 **** --- 62,72 ---- import jdk.internal.misc.JavaUtilZipFileAccess; import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.VM; import jdk.internal.perf.PerfCounter; import jdk.internal.ref.CleanerFactory; + import jdk.internal.vm.annotation.Stable; import static java.util.zip.ZipConstants64.*; import static java.util.zip.ZipUtils.*; /**
*** 96,113 **** public class ZipFile implements ZipConstants, Closeable { private final String name; // zip file name private volatile boolean closeRequested; ! private ZipCoder zc; // The "resource" used by this zip file that needs to be // cleaned after use. // a) the input streams that need to be closed // b) the list of cached Inflater objects // c) the "native" source of this zip file. ! private final CleanableResource res; private static final int STORED = ZipEntry.STORED; private static final int DEFLATED = ZipEntry.DEFLATED; /** --- 97,114 ---- public class ZipFile implements ZipConstants, Closeable { private final String name; // zip file name private volatile boolean closeRequested; ! private final @Stable ZipCoder zc; // The "resource" used by this zip file that needs to be // cleaned after use. // a) the input streams that need to be closed // b) the list of cached Inflater objects // c) the "native" source of this zip file. ! private final @Stable CleanableResource res; private static final int STORED = ZipEntry.STORED; private static final int DEFLATED = ZipEntry.DEFLATED; /**
*** 367,377 **** * @throws IllegalStateException if the zip file has been closed */ public InputStream getInputStream(ZipEntry entry) throws IOException { Objects.requireNonNull(entry, "entry"); int pos = -1; ! ZipFileInputStream in = null; Source zsrc = res.zsrc; Set<InputStream> istreams = res.istreams; synchronized (this) { ensureOpen(); if (Objects.equals(lastEntryName, entry.name)) { --- 368,378 ---- * @throws IllegalStateException if the zip file has been closed */ public InputStream getInputStream(ZipEntry entry) throws IOException { Objects.requireNonNull(entry, "entry"); int pos = -1; ! ZipFileInputStream in; Source zsrc = res.zsrc; Set<InputStream> istreams = res.istreams; synchronized (this) { ensureOpen(); if (Objects.equals(lastEntryName, entry.name)) {
*** 602,614 **** } private String getEntryName(int pos) { byte[] cen = res.zsrc.cen; int nlen = CENNAM(cen, pos); ! int clen = CENCOM(cen, pos); ! int flag = CENFLG(cen, pos); ! if (!zc.isUTF8() && (flag & EFS) != 0) { return zc.toStringUTF8(cen, pos + CENHDR, nlen); } else { return zc.toString(cen, pos + CENHDR, nlen); } } --- 603,613 ---- } private String getEntryName(int pos) { byte[] cen = res.zsrc.cen; int nlen = CENNAM(cen, pos); ! if (!zc.isUTF8() && (CENFLG(cen, pos) & EFS) != 0) { return zc.toStringUTF8(cen, pos + CENHDR, nlen); } else { return zc.toString(cen, pos + CENHDR, nlen); } }
*** 1216,1226 **** static Source get(File file, boolean toDelete) throws IOException { Key key = new Key(file, Files.readAttributes(file.toPath(), BasicFileAttributes.class)); ! Source src = null; synchronized (files) { src = files.get(key); if (src != null) { src.refs++; return src; --- 1215,1225 ---- static Source get(File file, boolean toDelete) throws IOException { Key key = new Key(file, Files.readAttributes(file.toPath(), BasicFileAttributes.class)); ! Source src; synchronized (files) { src = files.get(key); if (src != null) { src.refs++; return src;
< prev index next >