ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Reilly <>
Subject Re: antlibs and classloaders #2
Date Mon, 17 May 2004 13:06:50 GMT
Jose Alberto Fernandez wrote:

>>From: Peter Reilly [] 
>>I meant to respond to this earlier, but did not get the chance.
>>1) use of classpath in an antlib.
>>I have tested using a classpath within an antlib:
>>~/.ant/lib/x_call.jar containing:
>>  <typedef resource="x/antlib.xml">
>>    <classpath path="${user.home}/apps/x/x.jar"/>
>>  </typedef>
>>This works fine, but depends on a possible bug in ant
>>see: bugzilla 28782
>>The problem is that the typedef in the antlib should pick up 
>>two antlib.xml resources, the one in  
>>"${user.home}/apps/x/x.jar" and the one in x_call.jar 
>>(itself). This will should cause no-ending recursion.
>>The bug means that this does no happen - the resources in the 
>>parent classloader are currently not visible to the child 
>>If the bug is fixed, an infinite recursion will happen.
>>This could be stopped by typedef checking if it has already 
>>been executed.  This can be done by using "user" properties - 
>>but this will pollute the property names, or by exending 
>>(again) Project to have a map of objects that gets copied to 
>>its child projects. Using non-user properties or references 
>>will not work as <*ant*> tasks can stop the non-user 
>>properties and references being copied to the child 
>>processes. Using a static map in typedef will not work as 
>>sibling projects will incorrectly interact.
>This things sound like we are using the wrong abstraction here.
><typedef/> inside an <antlib/> should use the antlib classloader
>as the parent for any subsequent classloader.
In this case the parent is the antlib classloader (it is the default 

>I do not see why that should cause an infinite recursion.
The problem is that the <typedef resource="net/.../antlib.xml">
<classpath path="cpptasks.jar"/> </typedef> in
the antlib will pick up the antlib.xml resoure that contains <typedef 
task which will pick up .....,

This does not happen with the current ant code, as the <typedef 
  <classpath path="cpptasks.jar"/></typedef>
task will not see the antlib.xml resource in the parent classloader.

Another way to work-around this is for the typedef to use a thread 
specific stack to check
for recursive loading of xml resources.
This probally should be done in any case:


   <typedef file="recursive.xml"/>

  <typedef file="recursive.xml"/>


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

View raw message