Patch for JDK 1.5 ZipFile to fix slow network drive access
First published 7 September 2005.
There is a problem with java.util.ZipFile in JDK 1.5 that it is very slow to perform some operations when the ZIP/JAR file is on a network drive. See this bug report.
This patch is based on the source for ZipFile from JDK 1.5.0_04. It is intended for use on Windows only (but see Limitations). The download includes source, a compiled version of the patch and a Windows .BAT file for installing it.
The installation just involves adding the patched classes into your rt.jar file for your Java runtime environment.
Patch Detail
The patched java.util.ZipFile looks at the path of the zip/jar file when trying to open it. If it determines that the path is on a network drive it instead copies it to a location on your local drive and uses that copy instead. If the copy already exists it checks the timestamps to ensure it is up to date. Copies are stored in the temporary directory on your system as determined by System.getProperty("java.io.tmpdir").
This results in a massive speed-up for accessing zips/jars on network drives, and a small cache of zips/jars on your local drive.
In the source code the patch changes are all between the /* PATCH BEGINS */ and /* PATCH ENDS */ comments. The rest is the original code.
Limitations
The patch is written with Windows in mind, as it checks for C: at the start of the full path in order to determine whether the file is on a network drive or not! This obviously won’t work very well for other operating systems. It will be really easy to change the patch to suit those requirements though. The source is included in the download; if you do this please let me know so that I can add your efforts to this page.
Installation Instructions
You can download the patch here. There is a readme file in the ZIP.