You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Steve Loughran <st...@iseran.com> on 2002/05/03 09:03:40 UTC

[Patch] AntClassloader.java

OK,

here is the first iteration on a patch to handle the fatter distro of
java1.4, part of my todo list for ant1.5

I have run ant test on this on 1.4, but am yet to write the tests to verify
that the classloading stuff works. Or more importantly, the tests to verify
that on java1.3 we dont get xalan or crimson in there. I may have a go next
week, while I sit in a meeting room somewhere just east of seattle. There's
something deeply amusing about the idea of coding open source java inside
the MS campus.

Anyhows. I wanted to bounce this source by to see how much it abused the
style rules. I'd have like JavaEnvUtils to have given me the java version
numerically...half this patch turns the strings into numbers, numbers that I
switch on with a fallthrough to always load the previous versions system
packages too.

I have left a placeholder for java1.5 in there too.

-steve

Index: AntClassLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/AntClassLoader.java,v
retrieving revision 1.52.2.1
diff -r1.52.2.1 AntClassLoader.java
73a74
> import org.apache.tools.ant.util.JavaEnvUtils;
321,322c322
<         addSystemPackageRoot("java");
<         addSystemPackageRoot("javax");
---
>         addJavaLibraries();
1176a1177,1224
>     }
>
>     /**
>      * add any libraries that come with different java versions
>      * here
>      */
>     private void addJavaLibraries() {
>         //turn the version into an integer
>         int version=10;
>         String javaVersion=JavaEnvUtils.getJavaVersion();
>         if(javaVersion.equals(JavaEnvUtils.JAVA_1_1)) {
>             version=11;
>         } else if(javaVersion.equals(JavaEnvUtils.JAVA_1_2)) {
>             version=12;
>         } else if(javaVersion.equals(JavaEnvUtils.JAVA_1_3)) {
>             version=13;
>         } else if(javaVersion.equals(JavaEnvUtils.JAVA_1_4)) {
>             version=14;
>         } else {
>             //whatever it is, it is newer than what we know here
>             version=15;
>         }
>         //now switch off that, falling through as we go
>         //we are assuming that each version of java
>         //is a superset of the previous version
>         switch(version) {
>             case 15:
>             case 14:
>                 addSystemPackageRoot("org.apache.crimson");
>                 addSystemPackageRoot("org.apache.xalan");
>                 addSystemPackageRoot("org.apache.xml");
>                 addSystemPackageRoot("org.apache.xpath");
>                 addSystemPackageRoot("org.w3c.dom");
>                 addSystemPackageRoot("org.xml.sax");
>                 // fall through
>             case 13:
>                 addSystemPackageRoot("org.omg");
>                 // fall through
>             case 12:
>                 addSystemPackageRoot("");
>                 // fall through
>             case 11:
>             default:
>                 addSystemPackageRoot("java");
>                 addSystemPackageRoot("javax");
>                 break;
>         }
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>