History log of /libcore/luni/src/main/java/java/util/zip/ZipFile.java
Revision Date Author Comments
12f5c69e074d6ef012706068416f0a61b70b4e52 27-Jan-2015 Narayan Kamath <narayan@google.com> Implement zip64 support for ZipFile/ZipInputStream/ZipOutputStream.

There are several open questions that I hope to resolve in future
changes :

- Our heuristics for detecting whether a zip outputstream should
switch over to zip64 or not are imprecise.

- Also, given that we now officially support zip64, we have to assume
new entries whose size is unknown need the zip64 header / footer.
This will make output files slightly larger and less compatible with
older tools. If we don't do this, we'll have to go back and rewrite &
compact parts of the stream we'd already flushed, which isn't always
possible. The other option is to assume zip32 for streams of unknown
length and throw if more than 4G of data is written to them.

Change-Id: Ibb4a97b5f83fd3ab850d7c407ecfda663968a6b9
0aff1dd0b4be1b8d8cb45b59079ca883a1b3205a 17-Jun-2014 Elliott Hughes <enh@google.com> Remove.

(cherry-pick of 63744c884dd4b4f4307f2b021fb894af164972af.)

Change-Id: Ibf79a402e1bad98a262e380fcee3d35c127ae6d5
63744c884dd4b4f4307f2b021fb894af164972af 17-Jun-2014 Elliott Hughes <enh@google.com> Remove.

Change-Id: Ibf79a402e1bad98a262e380fcee3d35c127ae6d5
e8a958066d95a4e15a9834e8b9067d106efd9b53 15-Jun-2014 Elliott Hughes <enh@google.com> @hide.

Change-Id: Ieacf34a7b850910e70ae54f738608509e2c39e2e
e9ed1b1450852172a48f9811ebb09d25f2f7e140 08-May-2014 Neil Fuller <nfuller@google.com> Unhide further 1.7-era APIs

Change-Id: I15ef2991b03a9503d6917a7f3351b32f42f662fb
a6f350c645dbb66d68cc2b03afb8f2eeaa88fbba 28-Feb-2014 Paul Duffin <paulduffin@google.com> Improve detection of CloseGuard protected resource leakage

* Add CloseGuardMonitor to intercept and collate CloseGuard reports and if
necessary throw an exception listing the resource leaks.
* Add ResourceLeakageDetector to abstract away the CloseGuardMonitor which will
not work on RI.
* Add AbstractResourceLeakageDetectorTestCase as a base class for tests
that need to detect resource leaks, in future this could be handled by
modifications to Cts and Vogar test runners.
* Remove CloseGuardTester and its sole usage in ProcessBuilderTest.
* Remove CloseGuardGuard from within URLConnectionTest
* Change ZipFileTest, ProcessBuilderTest, URLConnectionTest to use new
mechanism, fix issues that are identified and do some cleanup/remove
duplicated code.

Bug: https://code.google.com/p/android/issues/detail?id=66383
Change-Id: Id026dbb6bc66091a15f07329e6371cd0d1f32cf5
e3d756c5dae1af2aa5f0ad8bc7f133df3e7401eb 11-Mar-2014 Neil Fuller <nfuller@google.com> Add Java 1.7 APIs: ZipFile, ZipInputStream, ZipOutputStream

Add constructor support for the character encoding to use.

When reading a ZipFile this is used for the file comment and for
entry names and comments when a zip entry is not self-described
as UTF-8 encoded.

When writing a zip file the character encoding determines the
encoding used for the file comment, entry names and comments.

The default for reading and writing when the character encoding
is not specified remains as UTF-8.

Additional fix:
ZipOutputStream: null comments no longer cause NullPointerException.

Change-Id: I7cadfa939377d0f87fd5503dae2a0b2dbac2ba39
ef164bf196538c04f499dcbb49a389c70ff5601a 26-Feb-2014 Paul Duffin <paulduffin@google.com> Improve error message when attempting to open an empty zip

The bug report states that the behaviour of ZipFile has changed between 4.3 and
4.4 when opening an empty zip file. I did some investigation and it appears as
though the reference implementation also throws an exception in that case so I
decided that 4.4 is working as designed. However, to make it clearer I made a
minor change to explicitly check for an empty zip file so that we can report a
slightly improved message explaining that they are not supported. I added a
test for various forms of empty streams and zip files and removed part of an
older test from harmony tests as it is no longer necessary.

Bug: https://code.google.com/p/android/issues/detail?id=65380
Change-Id: I1f2fcbf6bbaedb7dbccf8dd4f1cec4e330274524
0c1869ed7f46baf764f9daf4e64c77cd7fbd3516 29-Nov-2013 Narayan Kamath <narayan@google.com> Add a JNI wrapper over libziparchive.

All functions delegate directly to the native code. We
do not perform any sort of central directory or local file
related lookups in the java layer.

For each entry, libziparchive gives us an offset to the start
of data for the entry and the compressed size. We use a
RandomAccessFile to seek to that offset and then construct an
InputStream that's bounded between [offset, offset + compressed_size).

We reuse existing code (JarVerifier / Manifest) for certificate
validation & collection.

bug: 10193060

Change-Id: I21eb4e6dc6aa8749e3f63830f9799e1f621d26e6
34f81a14c7c4002ab141ba90b2498974211b7df2 02-Oct-2013 Kenny Root <kroot@google.com> ZipFile: fix comparison for offset, pt 2

Also remove the "byteOffset" value for the length calculation.

Bug: 10947135
Change-Id: I6cbe3ed5552cd595020e8f3d0099daab6cada88e
81e81ce7aa930332cbc35d06809b11b6d8fe2251 27-Sep-2013 Kenny Root <kroot@google.com> ZipFile: fix comparison for offset

The "byteOffset" value for the reading buffer was being checked against
the RandomAccessFile length value which didn't make much sense. Remove
that line to restore sanity.

Bug: 10947135
Change-Id: I4f85f5f1e162aeb19ff876a32e5b22bb876aacdb
3d2b2ad2cd1f05ba72a550082083da4b5898f30b 11-Sep-2013 Kenny Root <kroot@google.com> Revert "Revert "Reconcile differences between zip implementations""

This reverts commit c2bcd6f029fa02657889af1120f2eaaf73da968e.

Bug: 10424836
Change-Id: I63f801c4f451383bfadd9c76f99c3ebb2726e7b0
c2bcd6f029fa02657889af1120f2eaaf73da968e 11-Sep-2013 Kenny Root <kroot@google.com> Revert "Reconcile differences between zip implementations"

This reverts commit bb68396d3c4262760055101cbf18c80999c692f5.

Change-Id: I56daf02fe24cc592844a5d0a9f1ca7432da2293e
bb68396d3c4262760055101cbf18c80999c692f5 21-Aug-2013 Kenny Root <kroot@google.com> Reconcile differences between zip implementations

Reconcile the difference between ZipFileRO and java.util.ZipFile to have
the same behavior.

Bug: 10424836
Change-Id: I6dcbb5234142dc8574052be2b18f062ef2e93b02
44e8930b48015aacbad027c5a8d9a4c7e00e329e 06-Aug-2013 Elliott Hughes <enh@google.com> Bumper ZipFile/ZipEntry backport.

Bug: https://code.google.com/p/android/issues/detail?id=58465
Bug: 8219321
Bug: 8476102
Bug: 8617715
Bug: 9695860
Bug: 9950697
Bug: 10148349
Bug: 10227498
Change-Id: I94c3e9664a429c94c336115618a46283a13996e0
87f155f5761977276cd2aff66afe9312aefec02d 08-Aug-2013 Chad Brubaker <cbrubaker@google.com> Use uncompressed size for uncompressed zip entries

Use the uncompressed size when setting the length of entries stored
without compression, conistent with the other Zip implementations.

Bug: 10148349
Change-Id: I7559a32b1190d27d9e8e2bd3dd419171e971644d
2da1bf57a6631f1cbd47cdd7692ba8743c993ad9 21-Jul-2013 Elliott Hughes <enh@google.com> Fix ZipFile local file entry parsing.

The file name length is given in both the central directory entry
and the local file entry, with no consistency check. ZipInputStream
and the VM's native code both use the local file entry's value but
ZipFile was using the value from the central directory.

This patch makes ZipFile behave like the other two. (Even though,
unlike the others, ZipFile actually has enough information to detect the
inconsistency and reject the file.)

Bug: https://code.google.com/p/android/issues/detail?id=57851
Bug: 9950697
Change-Id: I1d58ac523ad2024baff1644d7bf822dae412495d
(cherry picked from commit 257d72c1b3a69e0af0abe44801b53966dbf7d214)
339f18ff18ea0c13fae1d6750ffe8eaf847e62e9 04-Jul-2013 Elliott Hughes <enh@google.com> Values in ZIP files are unsigned.

Bug: 9695860

(cherry picked from commit 9edf43dfcc35c761d97eb9156ac4254152ddbc55)

Change-Id: Ic14eac58fdcfc343a9e23df8c26ba0dd24c9e189
fe39951ed36353002263aefef7963a8c8b9c6441 04-Jul-2013 Elliott Hughes <enh@google.com> Values in ZIP files are unsigned.

Bug: 9695860
Change-Id: I5c12dc5f3c70a9fe081adf5bf5b6b4b3a115e7e1
(cherry picked from commit 9edf43dfcc35c761d97eb9156ac4254152ddbc55)
7f649edc647081ac299742607d7c497486ff41a7 04-Jul-2013 Elliott Hughes <enh@google.com> Values in ZIP files are unsigned.

Bug: 9695860

(cherry picked from commit 9edf43dfcc35c761d97eb9156ac4254152ddbc55)

Change-Id: Ic14eac58fdcfc343a9e23df8c26ba0dd24c9e189
9edf43dfcc35c761d97eb9156ac4254152ddbc55 04-Jul-2013 Elliott Hughes <enh@google.com> Values in ZIP files are unsigned.

Bug: 9695860
Change-Id: I5c12dc5f3c70a9fe081adf5bf5b6b4b3a115e7e1
820c09bae53d20c5954d544ebc8a6ee8e54abbae 29-Jun-2013 Elliott Hughes <enh@google.com> Implement ZipFile.getComment.

Bug: 3484927
Change-Id: I30c30799aed1b3bbd1b2c90825685cea457600d1
325ff8c68ed5e530e9e1d487b9e2e6d8f8e2bd37 25-Jun-2013 Elliott Hughes <enh@google.com> Clean up the #read javadoc.

By being more consistent in parameter naming, we can inherit more javadoc.

Also fix a couple of javadoc warnings in KnownFailure and DataInputStream.

Change-Id: I778f40469404fb50c51cdb1068970974f923180c
9902f3494c6d983879d8b9cfe6b1f771cfefe703 10-May-2013 Elliott Hughes <enh@google.com> Finish off AutoCloseable.

Bug: 3484927
Change-Id: Ia0f5ad3db9807459ce6cda05bc2f53564b63b375
25681be69e19a834b00cfbf54cd99ac13f12b9ff 17-Apr-2013 William Luh <williamluh@google.com> Only enforce the encrypted bit in the GPBF, and ignore other unsupported bits.

(cherry-pick of 7a302a49a7c8b99e2f34fff660e199fb7c776bc1.)

Bug: 8617715
Change-Id: Ibfe919d67fd17cee050d23811faa5aa64116dfb4
941d18fe01a8b2b69c67a006d1f3d855bdccde95 17-Apr-2013 William Luh <williamluh@google.com> Only enforce the encrypted bit in the GPBF, and ignore other unsupported bits.

Bug: 8617715
Change-Id: I2f906ae6107d2bdf990a7991f56d4a0873bca634
7a302a49a7c8b99e2f34fff660e199fb7c776bc1 17-Apr-2013 William Luh <williamluh@google.com> Only enforce the encrypted bit in the GPBF, and ignore other unsupported bits.

Bug: 8617715
Change-Id: I2f906ae6107d2bdf990a7991f56d4a0873bca634
6aed748da1deaa820d574446037401893d73be9b 02-Apr-2013 William Luh <williamluh@google.com> Don't install APK files with unsupported General Purpose Bit Flag bits.

Bug: 8476102

(cherry picked from commit d0bd4c19678429b19ac4b9c7477b28241d5dd1db)

Change-Id: I03f19095ac4e6f8abcb61ba6c120227c2df1f2d1
d0bd4c19678429b19ac4b9c7477b28241d5dd1db 02-Apr-2013 William Luh <williamluh@google.com> Don't install APK files with unsupported General Purpose Bit Flag bits.

Bug: 8476102
Change-Id: I764c2aec944558129c8ac04ee0593fb3de82870e
84cfe1efaa3cff57b3a4926b37a16f2be8ed4c8e 05-Mar-2013 Geremy Condra <gcondra@google.com> convert mEntries -> entries to fix build.

Change-Id: Icce5d9730775253879053e0ca0db7e4e7f2e37b1
546d3cdd7bdb8ed40c04c28074c35a8cea767265 05-Mar-2013 Geremy Condra <gcondra@google.com> Convert mEntries -> entries, fixing the build.

Change-Id: Ica2cd26f12423f37707ab6f96225d3a994fbb9db
c7bcde8fbc5cff6de0b2581ebf7398c83e999410 19-Feb-2013 Geremy Condra <gcondra@google.com> Remove support for duplicate file entries.

Bug: 8219321
Change-Id: Ibc56bea753917c38e1bb20df48aa45fdff39d364
4beeee879af7581d6b3c28246a7cebe608f8e3a0 01-Mar-2013 Geremy Condra <gcondra@google.com> Revert "Remove support for duplicate file entries."

This reverts commit 5360af4aa1d23fd910680b09fa06f0820db03a9a

Ugh, forgot that make wouldn't make the tests anymore. We're missing the ZipException, I'll reupload in a second.

Change-Id: I8b4d7300cffa1f9f23235e2e33a1cf2b522ba3f3
5360af4aa1d23fd910680b09fa06f0820db03a9a 19-Feb-2013 Geremy Condra <gcondra@google.com> Remove support for duplicate file entries.

Bug: 8219321
Change-Id: I4ac47f8facf13afa45799a0d5e20202a0ef5f0c6
38cad1eb5cc0c30e034063c14c210912d97acb92 19-Feb-2013 Geremy Condra <gcondra@google.com> Remove support for duplicate file entries.

Bug: 8219321
Change-Id: I4ac47f8facf13afa45799a0d5e20202a0ef5f0c6
f05aeedc00c8e7ab7650067ce1dc301547a3914b 10-Dec-2012 Elliott Hughes <enh@google.com> More java.util.zip documentation improvements.

Change-Id: I8ebc23b8a7a7affee0fd3756c3861cf5b6c07ee4
13f30b9167639ad63da1707102db6320e8f76474 08-Dec-2012 Elliott Hughes <enh@google.com> Clean up ZipFile a little, fix a few bugs, and improve the documentation.

The main bug fixed is fixing support for .zip files larger than 2GiB (where
the central directory offset's top bit is set).

We were checking character counts rather than byte counts in several places
too, which could lead to corrupt zip files.

I've also added a comment to readCentralDirectory because I keep coming back
to this code, wanting to make it lazy, and never remember (until I've done
half the work) why that's not possible.

I've also clarified a lot of the documentation.

Bug: http://code.google.com/p/android/issues/detail?id=36187
Change-Id: Iaa8eadc501ead7c70528bd9063d5893a325dcea1
cff1616012dc0d56c2da9af2b9b1183e76c7e044 04-Dec-2012 Elliott Hughes <enh@google.com> Add detail messages to all the easy IllegalArgumentException cases.

Noticed during my recent Matcher change.

Change-Id: I415d911b26d0ee548ca04d56bba7fc3d4e6b3f88
d43b9ef11a1095967a3396b246639b563e1a4128 12-Sep-2012 Kenny Root <kroot@google.com> Add consistent reasons for NullPointerException

Semi-automated replacement of empty and non-conforming
NullPointerException reason messages.

(cherry-pick of 86acc043d3334651ee26c65467d78d6cefedd397.)

Change-Id: I6d893979f5c20a50e841e32af9fd7b2d8bc9d54d
86acc043d3334651ee26c65467d78d6cefedd397 12-Sep-2012 Kenny Root <kroot@google.com> Add consistent reasons for NullPointerException

Semi-automated replacement of empty and non-conforming
NullPointerException reason messages.

Change-Id: Iedeb4b21949e973c4042ce5982dda315f2e785e1
9f050bd1d16b822532430c897991e27a58605ff5 11-Jan-2012 Elliott Hughes <enh@google.com> Fix an ICS regression with zip files containing >= 32768 entries.

The usual signed/unsigned 16-bit field problem with zip files. In adding a unit
test I also found two other long-standing bugs:

1. We had O(N^2) behavior when adding files. Someone used an List where they
wanted a Set. Fixed by switching that code over to a Set.

2. We were allowing people to create .zip files with > 64Ki entries but
generating a file that would claim to have (entryCount & 0xffff) entries.
Fixed to throw ZipException until we have proper Zip64 support.

Bug: http://code.google.com/p/android/issues/detail?id=23207
Change-Id: Ice9c9790782639ba50e1ca057bc2cf21a945e147
ff8234c90ecab9f1db368924bf92a5b16460f9b5 08-Mar-2011 Elliott Hughes <enh@google.com> Factor out our single-byte InputStream.read/OutputStream.write implementations.

Change-Id: I00106a51a32ea84a39256d5629369170b892a039
fb0ec0e650bf8be35acb0d47da0311a7c446aa33 14-Jan-2011 Elliott Hughes <enh@google.com> Remove useless android-changed comments.

I've changed useful ones to regular comments or TODOs, as appropriate.

I've left ones in code like java.util.concurrent where we really are
tracking an upstream source, making the change markers useful.

I've left a handful of others where I intend to actually investigate
the implied TODOs before deciding how to resolve them.

Change-Id: Iaf71059b818596351cf8ee5a3cf3c85586051fa6
ad41624e761bcf1af9c8008eb45187fc13983717 07-Jan-2011 Elliott Hughes <enh@google.com> Retire SecurityManager.

This change removes all the code that was calling getSecurityManager, and
removes all use of AccessController.doPrivileged. It also changes the
implementation of AccessController so it doesn't actually do anything; it's
only there for source-level compatibility.

Bug: 2585285
Change-Id: I1f0295a4f12bce0316d8073011d8593fee116f71
f9480f317cddcec859025833b748f096247a40aa 08-Dec-2010 Elliott Hughes <enh@google.com> Fix InflaterInputStream and ZipInputStream's skip methods' behavior with negative counts.

This fixes a couple of harmony tests. I've also cleaned up all the names to be
of the form <x>Count. I haven't made much of an effort to improve the
documentation because these methods aren't all identical and I don't have a
good tool for doing large-scale javadoc consolidation.

Change-Id: Ia11f78cbe7c17959d50709af03042aa7541733a0
e43b3f6c7b343f4b6c738120a2ac2f93c5bd9a8e 10-Nov-2010 Elliott Hughes <enh@google.com> Fix a bug I introduced, and do more zip cleanup.

This code's quite hairy in its use of int/long. I can't just change the fields
to int because they seem to use -1L to mean "unset" while still allowing the
whole int range of values (including -1). We'll have to look at the zip
specification to see whether that's right, but for now, let's just avoid sign
extension.

I've also cleaned up some of the other code, most notably throwing more
detailed exception messages where it's easy, and removing hand-made readFully
implementations.

Bug: 3181430
Change-Id: I382568a8975c9b8b2ee5b344817134472369d308
43a9f774d075e0e441d8b996e3f6c81ea483ec89 19-Oct-2010 Elliott Hughes <enh@google.com> BufferIterator support for byte[].

Bug: 3032515
Change-Id: I040a92c3ce241aa97719ff94e3cc31c62473bf46
12f2d8e2760b78c673b7a187b9062b3938a03147 12-Oct-2010 Brian Carlstrom <bdc@google.com> Revised CloseGuard usage pattern

- CloseGuard.get() instants are now "unopened"
- In constructor cases, guard.open("...") is now at the end
- In metod cases, guard.open("...") is now after resource acquisition
- guard null pointer checks in finalizers in case constructor threw exception

Bug: 2645458
Change-Id: Ieb874a8c33b347768a9fa7437b3dd16f3d56d886
f7aab022dcbfcd8f27b409ab92b4bca4a84d0b8a 30-Sep-2010 Brian Carlstrom <bdc@google.com> CloseGuard: finalizers for closeable objects should log complaints

Introducing CloseGuard which warns when resources are implictly
cleaned up by finalizers when an explicit termination method, to use
the Effective Java "Issue 7: Avoid finalizers" terminology, should
have been used by the caller.

libcore classes that can use CloseGuard now do so.

Bug: 3041575
Change-Id: I4a4e3554addaf3075c823feb0a0ff0ad1c1f6196
e2f58c9501eac730d048199906dc41fe8e4cd6e9 29-Sep-2010 Brian Carlstrom <bdc@google.com> Scrub missing calls to super.finalize()

Bug: 3024226
Change-Id: I6642cb9d4929ba72244529efe4ebdfa595ae4fa7
739493443ce2ea5b0a92dd1725a4ed630db7b27b 23-Sep-2010 Elliott Hughes <enh@google.com> Simplify the ZipFile implementation, removing unbuffered I/O.

Bug: 3018772
Change-Id: I183e9ac597f9483418b0b337fc9e3944d473f359
c0c98ee1c95fd3b19646b4cb9771abf98a045ef0 23-Sep-2010 Elliott Hughes <enh@google.com> Remove unbuffered single-byte I/O from ZipFile.

This is enough to fool my current checking (and a little bit better than the
existing code), but I do plan on better checking and a rewrite of ZipFile.

Bug: 3018772
Change-Id: I607fee807c2bcbe9d59b883ef7bfbaa9a8f54ea8
7365de1056414750d0a7d1fdd26025fd247f0d04 12-Aug-2010 Jesse Wilson <jessewilson@google.com> Sorting imports.

Change-Id: I8347bc625480a1c37a1ed9976193ddfedeb00bbc
f33eae7e84eb6d3b0f4e86b59605bb3de73009f3 13-May-2010 Elliott Hughes <enh@google.com> Remove all trailing whitespace from the dalvik team-maintained parts of libcore.

Gentlemen, you may now set your editors to "strip trailing whitespace"...

Change-Id: I85b2f6c80e5fbef1af6cab11789790b078c11b1b
cec4dd4b1d33f78997603d0f89c0d0e56e64dbcd 26-Apr-2010 Peter Hallam <peterhal@google.com> merge more modules into luni