The attached patch includes several miscellaneous bugfixes, optimizations and simplifications that we created for Android's copy of the archive module. Here's an overview of what's changed:
Removes a bogus magic number check. Previously I submitted a patch to get this check to work; but the whole premise is flawed. To demonstrate, attempt to inflate data that was deflated using non-default settings.
InflaterInputStream, ZipInputStream, GZIPInputStream
These now make sure that available() returns 0 when the end of the stream is reached. Previously available() could return 1 even if read() was guaranteed to return -1.
Slight performance fix: cast from long to int only once
Verifies the entry when the last byte is returned. This is similar to the available() problem in ZipInputStream etc.
Move getMetaEntriesImpl() from native to Java.
Limit the amount of memory used while reading files. Previously we would create arbitrarily large buffers.
Move several methods from native to Java.
Keep resource bundles in memory with soft references
Use the system classloader always.
New tests to demonstrate problems above, recovery on broken manifests, verification of empty entries
Note that there are some problems with the patch, so it should not be applied! I will to upload an improved patch early next week. I figured I'd let everyone preview the patch in its current state; the problems are minor and include removing dead code and fixing tests with invalid assumptions.