ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jose Alberto Fernandez" <j_a_fernan...@yahoo.com>
Subject Dealing with ClassLoaders
Date Wed, 20 Feb 2002 02:01:07 GMT
Hi,

One of the things I think is broken in ANT1 is the way we deal with ClassLoaders. Our current
approach of having some of the code in the CLASSPATH and any other code being loaded
on independent ClassLoaders just causes all kinds of problems that only can be solved by
putting everything in the CLASSPATH of the JVM.

In the <antlib> proposal I am trying a different approach. Still certain things, like
core, will go in
the CLASSPATH, to obtain backward compatibility. Additional Classloaders will not be defined
by the jar files being added but by name. Every time a library is loaded, one specifies (implicitly
or
explicitly) the ClassLoader to use for loading its content.

In other words instead of creating more and more classloaders, one just add more and more
classes to an (maybe) existent classloader. By being able to identify which one we one to
use
we can accpomplish selective segregation of the classes when there are dependency clashes.

The third aspect, which I am considering right now, is to have three predetermine locations
for 
libraries:

1) $ANT_HOME/lib: this jars are added in the JVM's classpath.

2) $ANT_HOME/autolib/* : Any jars in subdirectories will be loaded at start-up on ClassLoaders
identified by the name of the subdirectory.

    $ANT_HOME/autolib/A/{a1.jar, a2.jar} :
        a1.jar and a2.jar will use ClassLoader "A".
    
    $ANT_HOME/autolib/B/{b1.jar, b2.jar} :
        b1.jar and b2.jar will use ClassLoader "B".

this will allow related libraries to se the same classloader and eliminate many of the current
issues.

3) $ANT_HOME/antlib: this is the location for libraries to be loaded on demand by using <antlib
library='x.jar'>
and one can specify which classloader to use.

To me this mechanism is much more simple to administrate, since in general people can first
try loading
everything in the default Classloader, and in case of a conflict they just need to change
where they want
to see what.

Comments, thoughts,

Jose Alberto



Mime
View raw message