reopen 353586
severity 353586 minor
thanks

I can reproduce this error using the attached very simple build.xml and
HelloWorld java program. Indeed, ant by default still automatically
adds /usr/share/ant/lib/ant-bootstrap.jar to the classpath. Note, though
that the warning occurs only when the -Xlint compilerarg is passed to
javac, and the warnings don't make anything fail, so I've downgraded the
severity of this bug to minor.

Just as a refresher, the output that ant build gives is

========================================================================
Buildfile: build.xml

build:
    [javac] Compiling 1 source file
    [javac] warning: [path] bad path element "/usr/share/ant/lib/xml-apis.jar": 
no such file or directory
    [javac] warning: [path] bad path element 
"/usr/share/ant/lib/xercesImpl.jar": no such file or directory
    [javac] warning: [path] bad path element "/usr/share/ant/lib/xalan.jar": no 
such file or directory
    [javac] 3 warnings

BUILD SUCCESSFUL
Total time: 2 seconds
========================================================================

Some Googling turns up that the above warnings may be a result of
extraneous things in the Class-Path attribute in the
META-INF/MANIFEST.MF file of a JAR. Indeed, when I
unjar /usr/share/ant/lib/ant-bootstrap.jar, I find in
META-INF/MANIFEST.MF the line

Class-Path: ant.jar xml-apis.jar xercesImpl.jar xalan.jar

Now, according to the documentation for the JAR file format [1], the
Class-Path attribute "specifies the relative URLs of the extensions or
libraries that this application or extension needs." This is why javac
is looking for xml-apis.jar, xercesImpl.jar, and xalan.jar
in /usr/share/ant/lib/ (the same directory as ant-bootstrap.jar) and not
in /usr/share/java/, where at least xercesImpl.jar lives. (Given that
ant now uses Xerces and not Xalan, it's interesting that xml-apis.jar
and xalan.jar still show up in this Class-Path line.)

[1] http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Main%20Attributes

Thus, this is indeed a bug in ant that the Class-Path attribute in
MANIFEST.MF in ant-bootstrap.jar is referencing non-existent jars.

Attachment: build.xml
Description: application/xml

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Reply via email to