ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: Real meaning of javac target/source attributes
Date Fri, 17 Feb 2006 05:15:48 GMT
On Thu, 16 Feb 2006, Jeffrey E. Care <> wrote:

> The only 100% safe way I know of to make sure you aren't using
> improper APIs is to make sure you are compiling against the class
> library from the *lowest common denominator* JDK version you need to
> support.

This is what happens in Ant as well.  During development from time to
time a committer will build and test Ant against a JDK 1.2.  And doing
so is part of the release process.

Actually it is even worse than that, you have to compile the binary
you publish using the lowest common denominator JDK, otherwise you may
end up with binaries that don't work on the "lower" VM even though the
source would compile fine.

Say we have class A with a method public void doSomething(Object o)
in version 1.2 and you invoke this in your code via doSomething("").
In version 1.3 an overload doSomething(String s) gets introduced.

If you compile on JDK 1.2 everything is fine and if you do so on JDK
1.3 it is as well.  But by compiling it on JDK 1.3 your class will be
looking for the String signature at runtime and your code will fail
with a NoSuchMethodError in a 1.2 VM.

There are several examples of this in the Java class library.

> There are other ways to accomplish this (and Ant itself makes use of
> some of those techniques) but you can't rely on those being 100%
> safe.

Such as?  I'm really curious.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message