summaryrefslogtreecommitdiffstats
path: root/archive
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-02-05 00:03:03 -0800
committerElliott Hughes <enh@google.com>2010-02-05 00:03:03 -0800
commit1d8bb71cc4f69089311416a8402f492b7af4784d (patch)
tree9f37e6376a73a0043a30409ee93c3f3613c5f520 /archive
parentf1de809dfc619c91cb0475ccc6e971665b618e42 (diff)
downloadlibcore-1d8bb71cc4f69089311416a8402f492b7af4784d.zip
libcore-1d8bb71cc4f69089311416a8402f492b7af4784d.tar.gz
libcore-1d8bb71cc4f69089311416a8402f492b7af4784d.tar.bz2
Fix accidental API pollution in java.util.zip.
Package-private interface ZipConstants turns out to be implemented by all the public Zip* classes in the package, so they can uselessly expose duplicate copies of the constants. This means I can't add my own constants there because they'll leak. This didn't break the build because we lose the "implements ZipConstants" and ZipConstants.class somewhere around the apicheck part of the build. See http://b/2421864 for that. Anyway, let's mop up the spill before anyone can see it...
Diffstat (limited to 'archive')
-rw-r--r--archive/src/main/java/java/util/zip/ZipConstants.java26
-rw-r--r--archive/src/main/java/java/util/zip/ZipFile.java20
-rw-r--r--archive/src/main/java/java/util/zip/ZipInputStream.java2
-rw-r--r--archive/src/main/java/java/util/zip/ZipOutputStream.java6
4 files changed, 29 insertions, 25 deletions
diff --git a/archive/src/main/java/java/util/zip/ZipConstants.java b/archive/src/main/java/java/util/zip/ZipConstants.java
index f0b1f69..4ce65bc 100644
--- a/archive/src/main/java/java/util/zip/ZipConstants.java
+++ b/archive/src/main/java/java/util/zip/ZipConstants.java
@@ -17,6 +17,11 @@
package java.util.zip;
+/**
+ * Do not add constants to this interface! It's implemented by the classes
+ * in this package whose names start "Zip", and the constants are thereby
+ * public API.
+ */
interface ZipConstants {
public static final long LOCSIG = 0x4034b50, EXTSIG = 0x8074b50,
@@ -30,25 +35,4 @@ interface ZipConstants {
CENNAM = 28, CENEXT = 30, CENCOM = 32, CENDSK = 34, CENATT = 36,
CENATX = 38, CENOFF = 42, ENDSUB = 8, ENDTOT = 10, ENDSIZ = 12,
ENDOFF = 16, ENDCOM = 20;
-
- /**
- * General Purpose Bit Flags, Bit 3.
- * If this bit is set, the fields crc-32, compressed
- * size and uncompressed size are set to zero in the
- * local header. The correct values are put in the
- * data descriptor immediately following the compressed
- * data. (Note: PKZIP version 2.04g for DOS only
- * recognizes this bit for method 8 compression, newer
- * versions of PKZIP recognize this bit for any
- * compression method.)
- */
- public static final int GPBF_DATA_DESCRIPTOR_FLAG = 1 << 3; // android-added
-
- /**
- * General Purpose Bit Flags, Bit 11.
- * Language encoding flag (EFS). If this bit is set,
- * the filename and comment fields for this file
- * must be encoded using UTF-8.
- */
- public static final int GPBF_UTF8_FLAG = 1 << 11; // android-added
}
diff --git a/archive/src/main/java/java/util/zip/ZipFile.java b/archive/src/main/java/java/util/zip/ZipFile.java
index 48541e1..6513622 100644
--- a/archive/src/main/java/java/util/zip/ZipFile.java
+++ b/archive/src/main/java/java/util/zip/ZipFile.java
@@ -43,6 +43,26 @@ import java.util.Iterator;
* @see ZipOutputStream
*/
public class ZipFile implements ZipConstants {
+ /**
+ * General Purpose Bit Flags, Bit 3.
+ * If this bit is set, the fields crc-32, compressed
+ * size and uncompressed size are set to zero in the
+ * local header. The correct values are put in the
+ * data descriptor immediately following the compressed
+ * data. (Note: PKZIP version 2.04g for DOS only
+ * recognizes this bit for method 8 compression, newer
+ * versions of PKZIP recognize this bit for any
+ * compression method.)
+ */
+ static final int GPBF_DATA_DESCRIPTOR_FLAG = 1 << 3; // android-added
+
+ /**
+ * General Purpose Bit Flags, Bit 11.
+ * Language encoding flag (EFS). If this bit is set,
+ * the filename and comment fields for this file
+ * must be encoded using UTF-8.
+ */
+ static final int GPBF_UTF8_FLAG = 1 << 11; // android-added
/**
* Open ZIP file for read.
diff --git a/archive/src/main/java/java/util/zip/ZipInputStream.java b/archive/src/main/java/java/util/zip/ZipInputStream.java
index ddebd6f..c2af30c 100644
--- a/archive/src/main/java/java/util/zip/ZipInputStream.java
+++ b/archive/src/main/java/java/util/zip/ZipInputStream.java
@@ -234,7 +234,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
throw new ZipException(Messages.getString("archive.22")); //$NON-NLS-1$
}
int flags = getShort(hdrBuf, LOCFLG - LOCVER);
- hasDD = ((flags & GPBF_DATA_DESCRIPTOR_FLAG) == GPBF_DATA_DESCRIPTOR_FLAG);
+ hasDD = ((flags & ZipFile.GPBF_DATA_DESCRIPTOR_FLAG) != 0);
int cetime = getShort(hdrBuf, LOCTIM - LOCVER);
int cemodDate = getShort(hdrBuf, LOCTIM - LOCVER + 2);
int cecompressionMethod = getShort(hdrBuf, LOCHOW - LOCVER);
diff --git a/archive/src/main/java/java/util/zip/ZipOutputStream.java b/archive/src/main/java/java/util/zip/ZipOutputStream.java
index f85e253..e53061a 100644
--- a/archive/src/main/java/java/util/zip/ZipOutputStream.java
+++ b/archive/src/main/java/java/util/zip/ZipOutputStream.java
@@ -140,7 +140,7 @@ public class ZipOutputStream extends DeflaterOutputStream implements
}
// Update the CentralDirectory
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT
- int flags = currentEntry.getMethod() == STORED ? 0 : GPBF_DATA_DESCRIPTOR_FLAG;
+ int flags = currentEntry.getMethod() == STORED ? 0 : ZipFile.GPBF_DATA_DESCRIPTOR_FLAG;
writeLong(cDir, CENSIG);
writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version created
writeShort(cDir, ZIPLocalHeaderVersionNeeded); // Version to extract
@@ -285,10 +285,10 @@ public class ZipOutputStream extends DeflaterOutputStream implements
// BEGIN android-changed
// Local file header.
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT
- int flags = currentEntry.getMethod() == STORED ? 0 : GPBF_DATA_DESCRIPTOR_FLAG;
+ int flags = currentEntry.getMethod() == STORED ? 0 : ZipFile.GPBF_DATA_DESCRIPTOR_FLAG;
// Java always outputs UTF-8 filenames. (Before Java 7, the RI didn't set this flag and used
// modified UTF-8. From Java 7, it sets this flag and uses normal UTF-8.)
- flags |= GPBF_UTF8_FLAG;
+ flags |= ZipFile.GPBF_UTF8_FLAG;
writeLong(out, LOCSIG); // Entry header
writeShort(out, ZIPLocalHeaderVersionNeeded); // Extraction version
writeShort(out, flags);