ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Checking the java version
Date Fri, 08 Nov 2002 14:11:26 GMT
On Fri, 8 Nov 2002, Ilja Preu <preuss@disy.net> wrote:

> I am using ${java.specification.version} instead of
> ${ant.java.version} - I don't know wether this makes a difference,
> though.

Yes, it does.

${java.specification.version} is a system property JVM implementors
can (must?) implement, but I'm not sure whether the rules are well
defined here.  I wouldn't bet that Kaffee will set it correctly for
example.

${ant.java.version} is what Ant has detected.  Ant's detection code
tries to load a certain set of classes that have been added in certain
Java versions, the code is

        try {
            javaVersion = JAVA_1_0;
            javaVersionNumber=10;
            Class.forName("java.lang.Void");
            javaVersion = JAVA_1_1;
            javaVersionNumber++;
            Class.forName("java.lang.ThreadLocal");
            javaVersion = JAVA_1_2;
            javaVersionNumber++;
            Class.forName("java.lang.StrictMath");
            javaVersion = JAVA_1_3;
            javaVersionNumber++;
            Class.forName("java.lang.CharSequence");
            javaVersion = JAVA_1_4;
            javaVersionNumber++;
        } catch (ClassNotFoundException ...

In a certain sense, this is more reliable than
${java.specification.version} as Ant detects what is there instead of
what the VM claims to be.

On the other hand, it will say that Kaffee is Version 1.2, even though
it doesn't ship Swing.

Stefan

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message