ant-dev mailing list archives

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

>>From: Peter Reilly [mailto:peter.reilly@corvil.com] 
>>
>>
>>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:
>>x/antlib.xml
>><antlib>
>>  <typedef resource="x/antlib.xml">
>>    <classpath path="${user.home}/apps/x/x.jar"/>
>>  </typedef>
>></antlib>
>>
>>This works fine, but depends on a possible bug in ant
>>see: bugzilla 28782
>>
>>http://issues.apache.org/bugzilla/show_bug.cgi?id=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 
>>classloaders.
>>
>>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 
classloader).

>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 
resource="net/.../antlib.xml">
task which will pick up .....,

This does not happen with the current ant code, as the <typedef 
resource="net/.../antlib.xml">
  <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:

recursive.xml

<antlib>
   <typedef file="recursive.xml"/>
</antlib>

build.xml:
<project>
  <typedef file="recursive.xml"/>
</project>


Peter


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


Mime
View raw message