Bug#738789: libhamcrest-java: FTBFS: bad class file: hamcrest-core-1.3.jar(org/hamcrest/Description.class)
ebourg at apache.org
Tue Mar 25 23:07:11 UTC 2014
This issue is really intriguing. When the build fails
hamcrest-core-1.3.jar is not corrupted (verified with zip --test) and
the compiled Description.class file is always the same (the md5sum is
constant in all cases).
The random aspect of this bug leads me to think it's a kind of race
condition between the part of the build that writes the jar and the part
that reads it, but everything is executed sequentially so I'm not sure
how this could actually happen.
On Googling the error message I found this interesting bit in a python
script used by Assembla to build Ant projects:
# Experience has shown that occasionally an ant build will cause an error
# like the following:
[javac] DellDXConnector.java:14: cannot access
[javac] bad class file:
[javac] unable to access file: corrupted zip file
[javac] Please remove or make sure it appears in the correct
subdirectory of the classpath.
[javac] import com.perfectsearchcorp.feed.Connector;
# This error appears to be caused by a bug in how either ant or java itself
# manages file handles for zip files on some platforms -- I think java is
# sometimes opening the file for read before the handle for write is fully
# released and flushed.
So it may be either an Ant bug (but I reviewed the jar task code and the
files seem to be properly closed) or a JVM bug on Linux.
A simple workaround would be to mount the directory containing the
hamcrest-core classes into the classpath instead of using the generated jar.
More information about the pkg-java-maintainers