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

Print this page

        

*** 34,43 **** --- 34,45 ---- import java.util.Vector; import java.util.Enumeration; import java.util.Set; import java.util.HashSet; import java.util.NoSuchElementException; + import java.security.AccessController; + import sun.security.action.GetPropertyAction; import static java.util.zip.ZipConstants64.*; /** * This class is used to read entries from a zip file. *
*** 76,85 **** --- 78,98 ---- initIDs(); } private static native void initIDs(); + private static final boolean usemmap; + + static { + // A system prpperty to disable mmap use to avoid vm crash when + // in-use zip file is accidently overwritten by others. + String prop = AccessController.doPrivileged( + new GetPropertyAction("sun.zip.disableMemoryMapping")); + usemmap = (prop == null || + !(prop.length() == 0 || prop.equalsIgnoreCase("true"))); + } + /** * Opens a zip file for reading. * * <p>First, if there is a security manager, its <code>checkRead</code> * method is called with the <code>name</code> argument as its argument
*** 194,204 **** } if (charset == null) throw new NullPointerException("charset is null"); this.zc = ZipCoder.get(charset); long t0 = System.nanoTime(); ! jzfile = open(name, mode, file.lastModified()); sun.misc.PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0); sun.misc.PerfCounter.getZipFileCount().increment(); this.name = name; this.total = getTotal(jzfile); } --- 207,217 ---- } if (charset == null) throw new NullPointerException("charset is null"); this.zc = ZipCoder.get(charset); long t0 = System.nanoTime(); ! jzfile = open(name, mode, file.lastModified(), usemmap); sun.misc.PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0); sun.misc.PerfCounter.getZipFileCount().increment(); this.name = name; this.total = getTotal(jzfile); }
*** 671,682 **** } } } ! private static native long open(String name, int mode, long lastModified) ! throws IOException; private static native int getTotal(long jzfile); private static native int read(long jzfile, long jzentry, long pos, byte[] b, int off, int len); // access to the native zentry object --- 684,695 ---- } } } ! private static native long open(String name, int mode, long lastModified, ! boolean usemmap) throws IOException; private static native int getTotal(long jzfile); private static native int read(long jzfile, long jzentry, long pos, byte[] b, int off, int len); // access to the native zentry object