ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <>
Subject RE: preprocessing java source
Date Mon, 09 Sep 2002 16:53:38 GMT
That's the way to go, but without the reflection please!!!

As Costin hammered out, you don't need reflection to deal with JDK specific
code (or platform), but simply to encapsulate dependent code (jdk or
platform) into various concrete implementations of an abstract type (class
or interface) defining all of the required functionalities. Then simply
select the right implementation at run-time, dynamically, using Java's great
dynamic loading abilities.

Then in Ant's <javac>, conditionally include/compile/package the correct
code depending on the jdk/platform, as Ant does itself when compiling its
optional jar.

This is the real reason you don't need pre-processors in Java. --DD

-----Original Message-----
From: Laurie Harper [] 
Sent: Monday, September 09, 2002 12:55 AM
To: Ant Developers List
Subject: Re: preprocessing java source

Re-read your list of downsides; these are all good reasons why Java doesn't
include a pre-processor.

Have you considered factoring out the JDK version dependent code and using
reflection to select the appropriate implementation at run-time? That way,
you eliminate the need for pre-processing to comile on any platform and, as
a bonus, you get to run on any platform -- not just the one you compiled on.

That's the way to deal with platform dependencies in an object oriented


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

View raw message