Invalid jar in classpath aborts the compilation and throws an exception

Jonathan Gibbons jonathan.gibbons at oracle.com
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 java.util.zip/jar code 
> doesn't allow. The issue reported in Ant is here 
> https://bz.apache.org/bugzilla/show_bug.cgi?id=66110.
>
> 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/Bz66110.java:1: error: cannot access com.abc
> package com.abc;
> ^
> 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