Invalid jar in classpath aborts the compilation and throws an exception

Jonathan Gibbons jonathan.gibbons at
Mon Jun 20 00:14:17 UTC 2022

At a minimum, javac should report an error that it cannot open the file, 
and not simply ignore it.  I think an error is warranted over a warning, 
because the compilation cannot determine if it has been adversely 
affected by the bad jar file.  Eventually, I would expect the error to 
cause javac to exit with a non-zero exit code. Once an error has been 
reported, javac may continue "for a while" but will give up at the next 
point that it checks the error status.

-- Jon

On 6/18/22 1:44 AM, Jaikiran Pai wrote:
> An user of Ant has reported an issue where their project's build fails 
> during compilation. The failure appears to be a result of a jar (in 
> the classpath) having entries that the Java's code 
> doesn't allow. The issue reported in Ant is here 
> In cases like these, should the javac tool just ignore such jar files 
> and continue with the compilation? At least for this specific issue 
> that jar which is failing doesn't contribute any classes/resources for 
> the compilation to succeed.
> The specific exception that gets thrown comes from the 
> ArchiveContainer which then propagates and ultimately results in a 
> compilation error which looks like:
> /foo/src/com/abc/ error: cannot access
> package;
> ^
> ZipException opening "bz66110badJar.jar": ZIP file can't be opened as 
> a file system because entry "/." has a '.' or '..' element in its name
> 1 error
> -Jaikiran

More information about the compiler-dev mailing list