Invalid jar in classpath aborts the compilation and throws an exception

Jaikiran Pai jai.forums2013 at gmail.com
Mon Jun 20 15:18:00 UTC 2022


Hello Jon,

In its current form, javac does exit with a non-zero exit code and does 
report the root exception. However, based on what you say, I'm guessing 
javac could be enhanced to do this specific error reporting differently? 
Did I understand it right? If so, should I be creating a JBS enhancement 
request for it?

-Jaikiran

On 20/06/22 5:44 am, Jonathan Gibbons wrote:
> 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://urldefense.com/v3/__https://bz.apache.org/bugzilla/show_bug.cgi?id=66110__;!!ACWV5N9M2RV99hQ!J2GfDkI71NhF8OZiNgI3K0QoMrV5vNjJhkjYy8nMgEI-F-WhFvyViHBKsIavFhzZJH2DWEBa8Rgf0F7lVVwh02HcZI3Weg$ .
>>
>> 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