ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Classloader question
Date Thu, 11 Oct 2001 00:00:08 GMT
On 10/10/01 7:32 AM, "Conor MacNeill" <conor@cortexebusiness.com.au> wrote:

> Ted,
> 
> 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 (www.javageeks.com/Papers) or my book
>> (www.manning.com/Neward3/). 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.

Why is that a problem?

> 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.

I don't understand this model.  What is the use case where it is 'accessed'
more than once?

What I assume you mean is that if a taskdef is used multiple times - in
which case I would argue that you want to toss the thing out and start
again.  I say that as I think of each ant task usage as a separate 'process'
that isn't tied to any other calls to that task (process).

geir

> 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.
> 
> Conor
> 
> 

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



Mime
View raw message