ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mariano Benitez <mari...@fuegolabs.com>
Subject antlibs and classloaders #2
Date Fri, 07 May 2004 14:14:27 GMT
I am at the edge of a mental crisis, I need help....


Can someone explain how antlib paths and tasks works, I have this 
situation that I cannot understand.


I defined this:

<project name="fuego.internal.test.include" basedir=".">

    <property name="xml.encoding" value="ISO-8859-1"/>
   
    <path id="fuego.internal.test.antlibs.path">
        <fileset dir="${fuego.basedir}/lib">
            <include name="fuegoexpress-antlib.jar"/>
            <include name="fuegoenterprise-antlib.jar"/>
            <include name="fuegoj2ee-antlib.jar"/>
            <include name="fuego-test-antlib.jar"/>
        </fileset>
    </path>
    <typedef resource="fuego/internal/test/ant/antlib.xml"       
uri="antlib:fuego.internal.test.ant"       
loaderRef="fuego.internal.test" 
classpathref="fuego.internal.test.antlibs.path"/>
    <typedef resource="fuego/tools/ant/enterprise/antlib.xml" 
uri="antlib:fuego.tools.ant.enterprise" loaderRef="fuego.internal.test" 
classpathref="fuego.internal.test.antlibs.path"/>
    <typedef resource="fuego/tools/ant/express/antlib.xml"    
uri="antlib:fuego.tools.ant.express"      
loaderRef="fuego.internal.test" 
classpathref="fuego.internal.test.antlibs.path"/>
    <typedef resource="fuego/tools/ant/j2ee/antlib.xml"          
uri="antlib:fuego.tools.ant.j2ee"          
loaderRef="fuego.internal.test" 
classpathref="fuego.internal.test.antlibs.path"/>
</project>

another Jar "fuegocore.jar" is in the classpath manifest of those jars, 
inside the fuegocore jar there is a clas "Loader".

When I am executing one of the tasks in the antlib I do this.

Inside an Utils.class static method:
        task.log("[LOADERS]  Loader Class [" + Loader.class.hashCode() + 
"/" + Loader.class.getClassLoader() + "]");
        task.log("[LOADERS]  Utils Class [" + Utils.class.hashCode() + 
"/" + Utils.class.getClassLoader() + "]");

and  this is the result I get when I run this multiple times in the same 
ant run.

[t:testsetup] [LOADERS]  Loader Class 
[6597453/java.net.URLClassLoader@affc70]
[t:testsetup] [LOADERS]  Utils Class 
[19551658/org.apache.tools.ant.loader.AntClassLoader2@153f67e]

[t:testsetup] [LOADERS]  Loader Class 
[6597453/java.net.URLClassLoader@affc70]
[t:testsetup] [LOADERS]  Utils Class 
[10520143/org.apache.tools.ant.loader.AntClassLoader2@9a9b65]

[t:testsetup] [LOADERS]  Loader Class 
[6597453/java.net.URLClassLoader@affc70]
[t:testsetup] [LOADERS]  Utils Class 
[28623319/org.apache.tools.ant.loader.AntClassLoader2@da90c]



the thing is: WHY THE LOADER CLASS IS ALWAYS THE SAME WHILE THE UTILS 
CLASS IS ALWAYS IN DIFFERENT ANT CLASSLOADERS!!!

Also, If I put a static {} block in the Loader class it is invoked many 
times, not only one as it should, being the same class the one being 
returned.

Please help,  I cannot understand what is causing this and the 
side-effect is that I get OutOfMemory errors when I run nightly batch tests.


Everything is appreciated.

MAriano

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


Mime
View raw message