Class Zip
- java.lang.Object
-
- com.google.turbine.zip.Zip
-
public final class Zip extends java.lang.ObjectA fast, minimal, and somewhat garbage zip implementation. This exists because graal doesn't yet supportZipFile, andZipInputStreamdoesn't have the performance we'd like (*). If you're reading this, you almost certainly wantZipFileinstead.If you're reading this because you're fixing a bug, sorry.
(*) A benchmark that iterates over all of the entries in rt.jar takes 6.97ms to run with this implementation and 202.99ms with ZipInputStream. (Those are averages across 100 reps, and I verified they're doing the same work.) This is likely largely due to ZipInputStream reading the entire file from the beginning to scan the local headers, whereas this implementation (and ZipFile) only read the central directory. Iterating over the entries (but not reading the data) is an interesting benchmark because we typically only read ~10% of the compile-time classpath, so most time is spent just scanning entry names. And rt.jar is an interesting test case because every compilation has to read it, and it dominates the size of the classpath for small compilations.
Implementation notes:
- Leading garbage may be supported, since the archive is read backwards using the central directory. Archives modified with zip -A may not be supported. Trailing garbage is not supported.
- UTF-8 is the only supported encoding.
- STORED and DEFLATE are the only supported compression methods.
- Zip files larger than Integer.MAX_VALUE bytes are not supported.
- The only supported ZIP64 field is ENDTOT. This implementation assumes that the ZIP64 end header is present only if ENDTOT in EOCD header is 0xFFFF.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classZip.EntryAn entry in a zip archive.static classZip.ZipIterableProvides anIterableofZip.Entryover a zip archive.
-