jdk/src/share/classes/java/util/zip/ZipOutputStream.java
changeset 16713 7824dded9821
parent 14342 8435a30053c1
child 17910 82d10099a8a6
--- a/jdk/src/share/classes/java/util/zip/ZipOutputStream.java	Mon Mar 25 18:14:52 2013 -0700
+++ b/jdk/src/share/classes/java/util/zip/ZipOutputStream.java	Tue Mar 26 13:34:54 2013 -0700
@@ -43,6 +43,20 @@
 public
 class ZipOutputStream extends DeflaterOutputStream implements ZipConstants {
 
+    /**
+     * Whether to use ZIP64 for zip files with more than 64k entries.
+     * Until ZIP64 support in zip implementations is ubiquitous, this
+     * system property allows the creation of zip files which can be
+     * read by legacy zip implementations which tolerate "incorrect"
+     * total entry count fields, such as the ones in jdk6, and even
+     * some in jdk7.
+     */
+    private static final boolean inhibitZip64 =
+        Boolean.parseBoolean(
+            java.security.AccessController.doPrivileged(
+                new sun.security.action.GetPropertyAction(
+                    "jdk.util.zip.inhibitZip64", "false")));
+
     private static class XEntry {
         public final ZipEntry entry;
         public final long offset;
@@ -534,8 +548,10 @@
         }
         int count = xentries.size();
         if (count >= ZIP64_MAGICCOUNT) {
-            count = ZIP64_MAGICCOUNT;
-            hasZip64 = true;
+            hasZip64 |= !inhibitZip64;
+            if (hasZip64) {
+                count = ZIP64_MAGICCOUNT;
+            }
         }
         if (hasZip64) {
             long off64 = written;