[jdom-interest] 1.1 Collections

Jason Hunter jhunter at collab.net
Mon Mar 5 15:03:07 PST 2001

Walker Joe wrote:
> Hi,
> I noticed some fancy footwork in the ant build script to fix the imports to
> work with JDK 1.1 collections. The section starts:
>   <target name="collections" if="coll.present" depends="prepare-src">
> It occurred to me that by adding the attached file to the project, it would
> be possible to add
>   import com.sun.java.util.collections.*;
> just after each
>   import java.util.*;
> And then get rid of a lot of ant trickery.
> Under JDK 1.1 with collection.jar on the classpath, the build would use jdk
> 1.1 collections, and under JDK 1.2+ without the extra jar, jdk 1.2 version
> is used. The Dummy.java simply stops the import com.sun...collection.*; from
> dying.
> I've used it on a project and it worked quite well.

Cool hack.

But to be honest, I'd rather have Ant tapdance during a JDK 1.1 build
than check in a com.sun.* class into JDOM.  It's a namespace we
shouldn't touch, and even worse, having references to com.sun.* will
make people who casually read the code think JDOM depends on classes
outside the JDK.


More information about the jdom-interest mailing list