ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conor MacNeill <>
Subject Re: Classloading: getContextClassLoader returns URLClassLoader in 1.6beta2
Date Wed, 05 Nov 2003 23:32:45 GMT
On Thu, 6 Nov 2003 07:23 am, Tushar Rahman wrote:
> Hello ,
> I have written a custom task. inside that task if I call
> Thread.currentThread().getContextClassLoader() , it returns
> sun.misc.AppClassLoader in Ant 1.5.4 and returns an instance of
> URLClassLoader in Ant 1.6beta2.
> However the custom task gets loaded by an instance of AntClassLoader in
> both the versions.
> is this a bug ? I think getContextClassLoader should return the instance of
> AntClassLoader that loaded my custom task.
> can someone please comment if this is a bug and if this is going to get
> fixed.

Ant does not currently set the context class loader to the classloader created 
for loading the task. 

In Ant 1.5.x, you are seeing the primordial loader since no context 
classloader is set in the Ant 1.5 core. In Ant 1.6, you are seeing the 
classloader used to launch Ant. It will have all the jars from Ant's lib 

I've thought about setting the context classloader a few times but it raises a 
few questions. Firstly it would need to be set prior to setting each property 
(the setXXX) methods in addition to the execute method. 
Then, if your task accepts a datatype (addXXX) method, should it be set to the 
classloader for your task or the the datatype in question. What about if you 
were to use another task when executing your task? You've got to know about 
the task's designated classloader (which may not be the loader actually used 
to load a class).


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

View raw message