ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conor MacNeill <co...@cortexebusiness.com.au>
Subject Re: Using classloader for Junit
Date Fri, 20 Jun 2003 01:17:44 GMT
On Fri, 20 Jun 2003 01:40 am, Nick Chalko wrote:
>
> The
> if (resourceName.startsWith("org.apache.tools.ant.taskdefs.optional."))
> {return useParentFirst;}
> HACK worked last night.
>
> I will try something a little cleaner tonight.

It might appear to work but can fail in subtle ways. I have had instances 
where the second invocation of a task would cause an error because it would 
bring classes into the VM which were there already leading to two different 
class instances with the same classname being reachable (loader constraint 
violation).

This can be quite non-deterministic. If I installed a delay, the first load of 
classes would be GC'd avoiding the constaint violation by the second 
instance. So, I urge caution :-)

>
> >BTW, I don;t really agree with the <classloader> task being used to modify
> > the effective classpath of running ClassLoaders. I'm sure this will cause
> > trouble too.
>
> Seems to break some of the "properties are  immutable" philosophy of ant.

No - not really an Ant level issue. I am concerned by the scenario where a 
classloader with a child can not find a class on the first instance causing 
the child to load the class. If that class is later added to the loader's 
classpath, it becomes possible for parent to load the class and then we have 
a parent and child loader with the same class loaded ----> bad stuff happens.

Conor


-- 



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


Mime
View raw message