ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 11560] New: - Taskdef does not apply reverseLoader policy on standard tasks
Date Thu, 08 Aug 2002 14:18:27 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11560>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11560

Taskdef does not apply reverseLoader policy on standard tasks

           Summary: Taskdef does not apply reverseLoader policy on standard
                    tasks
           Product: Ant
           Version: 1.5
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Core tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: loic.peron@bigfoot.com


When using 'reverseLoader="true"' within a 'taskdef', standard ant tasks are 
not reloaded using the specified classpath

Explanation:

When Definer creates an AntClassLoader, it specifies "org.apache.tools.ant" as 
a system package root to uniquely load org.apache.tools.ant.Task and friends 
(otherwise breakages are to be expected)

But not all classes inside org.apache.tools.ant package and furthermore inside 
sub-packages need to be loaded only once, but instead can benefit from being 
reloaded using an extended classpath:

        <taskdef name="javac" classname="org.apache.tools.ant.taskdefs.Javac"
            reverseLoader="true">
            <classpath>
                <!-- contains tools.jar -->
                <fileset dir="${system.JAVA_HOME}/lib" includes="*.jar,*.zip" />
                <!-- contains ant.jar -->
                <fileset dir="${build.lib}" includes="*.jar,*.zip" />
            </classpath>
        </taskdef>

Workaround:

Set CLASSPATH with an external script which requires to re-code some of ant 
features like fileset and classpath using a non-portable script language
(as is done today) or bootstrap ant itself using a second JVM - both are 
similarly inefficient

Solution:

Force the currently re-defined class (as Definer is not only used for tasks) to 
be loaded by the AntClassLoader by addLoaderPackageRoot when reverseLoader is 
defined

---8<--------------------------------------------------------------
--- Definer.java.old	Tue Jul 09 11:28:38 2002
+++ Definer.java	Thu Aug 08 15:37:24 2002
@@ -224,9 +224,15 @@
      * create the classloader then hand the definition off to the subclass;
      * @throws BuildException when the class wont load for any reason
      */
-    private void addDefinition(ClassLoader al, String name, String value)
+    private void addDefinition(AntClassLoader al, String name, String value)
         throws BuildException {
         try {
+            // allow reload even for ant classes
+            if (reverseLoader) {
+                al.addLoaderPackageRoot(
+                        value.substring(0, value.lastIndexOf('.')));
+            }
+            
             Class c = al.loadClass(value);
             AntClassLoader.initializeClass(c);
             addDefinition(name, c);
---8<--------------------------------------------------------------

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message