|
List Info
Thread: classloader for 1.7
|
|
| classloader for 1.7 |

|
2006-08-30 15:49:31 |
|
On 8/30/06, Jesse Glick <sun.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">jesse.glick sun.com
> wrote:
Peter Reilly wrote: > So what would be the hier for the secondary class loader? > if it is bootstrap->ext->system->project->secondary,
Yes.
> it would meant that the classes in project would not be able to see the
> secondary classes.
Correct. Why is this a problem? Ant core classes should not be referring to tasks and such stuff. It is not much of a problem ---;)
Ok , I have done a prototype and the results look good:
1) a new ComponentClassLoader which is a AntClassLoader, except that a) it loads up with the classpath from Project.class.getClassLoader() and uses the paths from there to as its paths. b) it intercepts classes with "optional" or "ScriptRunner" in the name and loads these from
itself rather than from the parent classloader. both of these changes are to allow ant's optional classes to be loaded for the component class loader rather than from Project.class.getClassLoader()
c) set the parent classloader to Project.class.getClassLoader()
2) modify Project.java a) create a component classloader if is not created as a sub-project b) use this as a parent when Project.createClassLoader
() is called c) set the component classloader of sub-projects d) provide a public accessor for the component classloader
3) modify ComponentHelper a) use componentClassLoader when loading in tasks and types.
4) provide a task to add paths to the componentClassLoader
The end result looks like this: <project name="depend" default="depend" xmlns:ac="antlib:net.sf.antcontrib">
<target name="depend"> <!-- test for ant optional task - jdepend --> <appendcomponentpath> <fileset dir="c:/apps/jdepend-2.9.1/lib"/>
</appendcomponentpath> <jdepend> <classespath path="build/classes"/> </jdepend> <!-- test for ant lib -->
<appendcomponentpath> <fileset dir="${user.home}/p" includes="ant-con*.jar"/> </appendcomponentpath>
<ac:for param="param" list="a,b,c">
<sequential> <echo> </echo> </sequential> </ac:for> <!-- test for script --> <appendcomponentpath>
<fileset dir="${user.home}/lang/bsf" includes="*.jar"/> <fileset dir="${user.home}/lang/beanshell" includes="*.jar"/> </appendcomponentpath>
<script language="beanshell"> System.out | |