[fedora-java] Eclipse 3.2M5 and ant.java.version

Mark Wielaard mark at klomp.org
Sun Feb 19 17:03:57 UTC 2006


Hi Andrew,

On Sun, 2006-02-19 at 11:03 -0500, Andrew Overholt wrote:
> In the meantime, however, I found an issue with libcj and ant.java.version.
> 
> ant.java.version is the property that the Eclipse uses to determine what
> JVM/JDK is being used.  It is implemented like this [1]:
> 
>             Class.forName("java.lang.Readable");
>             javaVersion = JAVA_1_5;

Ugh, that is kind of a lame test. It is a feature test that is used to
set a global version. sigh. If you need a global version checking
System.getProperty("java.version") seems more appropriate.

We have the Readable, Closeable, Flushable interfaces since they don't
require any new 1.5 language or runtime features. If you would test like
the above a much better marker class would be java.lang.Enum since that
does need 1.5 language and runtime features being present.

I would propose either pushing a version check based on
System.getProperty("java.version"), or if upstream insists on class
loading based checks to change Readable to Enum.

> Is there a way we can get around this without patching ant or removing the
> 1.5 class library stuff from libgcj?

There might be an evil hack possible if you can force loading the ant
JavaEnvUtil class with a custom ClassLoader that overrides loadClass()
to explicitly disallow loading java.lang.Readable. That is extremely
ugly though and depends on finding the correct point in your application
that loads this specific ant task. It seems ant.java.version is set way
too early for such a hack to work easily though.

Does your application really need the ${ant.java.version}?
Can't it use ${java.version}?

Cheers,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/fedora-devel-java-list/attachments/20060219/ee4d9d22/attachment.sig>


More information about the fedora-devel-java-list mailing list