ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conor MacNeill <>
Subject Re: Classloader question
Date Wed, 10 Oct 2001 11:32:55 GMT

Ted Neward wrote:

> <ad>
> If you don't want to read the Liang/Bracha paper, might I humbly suggest
> some of the papers on my website ( or my book
> ( Bill Venners' "Inside the Java2 Virtual Machine"
> also does a good job of explaining ClassLoader delegation, as well.
> </ad>

Cool, I'll check them out.

> Conor, how hard would it be to simply set the context classloader in the
> main thread when Ant kicks off? (Threads inherit the context ClassLoader
> when spun off, so once set, it would be set for any and all threads created
> within Ant.) This would then make the "task classloader" easily available
> for any and all to use.

Well, the AntClassLoader provides methods to set and restore the context 
loader of the current thread so that part is relatively easy. It uses 
reflection so may not be the fastest routine. The main problem though is 
that there is not a single classloader for tasks but, potentially, one 
for each taskdef. Also tasks can be accessed in a variety of ways. 
Presumably, whenever the task is accessed, its loader would need to be 
set and then later restored. For all of the setXXX and createXXX methods 
of the task, the classloader would need to be setup and then also when 
the task is executed. This could be done in the Ant core introspection 
but further complications arise when tasks create other tasks. Who is 
responsible for setting the classloader in that case. It probably needs 
a bit more thought.


View raw message