We have a known corrupt jar file called saxorig.jar, but:
jar tvf saxorig.jar
...works fine.
A test program which opens the problem file as either JarFile or a ZipFile will fail:
(5.9)$ java ListJar saxorig.jar
Error accessing: saxorig.jar: java.util.zip.ZipException: error in opening zip file
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:112)
at java.util.jar.JarFile.<init>(JarFile.java:127)
at java.util.jar.JarFile.<init>(JarFile.java:65)
at ListJar.main(ListJar.java:11)
"jar tvf" would seem like a reasonable test for corrupt Jar/Zip files, but (some) corrupt files can pass that test, yet still be unusable. "jar xvf" can even extract all the files in the case of this specific instance of a captured corrupt jar file, while the classloader and the attached test program fail to open it.
(Yes, extracting and repackaging the jar fixes the problem.)
###@###.### 11/3/04 15:44 GMT
jar tvf saxorig.jar
...works fine.
A test program which opens the problem file as either JarFile or a ZipFile will fail:
(5.9)$ java ListJar saxorig.jar
Error accessing: saxorig.jar: java.util.zip.ZipException: error in opening zip file
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:112)
at java.util.jar.JarFile.<init>(JarFile.java:127)
at java.util.jar.JarFile.<init>(JarFile.java:65)
at ListJar.main(ListJar.java:11)
"jar tvf" would seem like a reasonable test for corrupt Jar/Zip files, but (some) corrupt files can pass that test, yet still be unusable. "jar xvf" can even extract all the files in the case of this specific instance of a captured corrupt jar file, while the classloader and the attached test program fail to open it.
(Yes, extracting and repackaging the jar fixes the problem.)
###@###.### 11/3/04 15:44 GMT
- duplicates
-
JDK-6227845 jar(1) command must have an option to validate a JAR-file
-
- Closed
-
- relates to
-
JDK-6189465 More error detail when encountering problems reading Zip files.
-
- Open
-
-
JDK-6189491 Silent failure of corrupt Jar/Zip files during classloading yields poor diagnosability.
-
- Closed
-