mpo's Blog
StevenN
TomK
Matthew
Kika | Mosh
Wiki (off-bridge)
acoliver
Carsten
Ovidiu
More Matthew...
Sam
Sylvain
Jeff
Simon
Bob
Werner
Marcus
Torsten
Bertrand
>Company Home<
[The Relevance]
[The References]
[The Blog-World]

Subscribe to "Marc, himself, his blogs, and you reading them" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.




...the eternal try-out.

Marc, himself, his blogs, and you reading them
 dinsdag 8 april 2003

Loading...

Classloader fun! This piece of code: (snippet from my XMLChainTask.java)

log("test : " + mpoObject.getClass().getName());
log("test : " + XMLFilterType.class.getName());
log("test : " + (XMLFilterType.class == mpoObject.getClass()));
XMLFilterType mpoFilter = (XMLFilterType)mpoObject;

kept on giving me:

test : XMLFilter{test([Marc=Portier])}
test : org.outerj.xml.filter.ant.XMLFilterType
test : org.outerj.xml.filter.ant.XMLFilterType
test : false

And the odd ClassCastException from the last line of code of course...

The only way two classes with exact names can be so 'different' is when they are loaded by different classloaders. The different classloaders is caused by ant looking at this:

<taskdef name="xmlchain" classname="org.outerj.xml.filter.ant.XMLChainTask" classpathref="load.cp"/>

<typedef name="xmlfilter" classname="org.outerj.xml.filter.ant.XMLFilterType" classpathref="load.cp" />

The classloader that created the XMLChainTask.class ended loading also the refered XMLFilterType.class and thus resulting error...

Snap ant code check comes to the rescue... inside org.apache.tools.ant.taskdefs.Definer.java there is this little hint to find:

<property name="ant.reuse.loader" value="true" />
3:40:50 PM    


April 2003
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
Mar   May

Click here to visit the Radio UserLand website.
Click to see the XML version of this web page. Click here to send an email to the editor of this weblog.
© Copyright 2003 Marc Portier.
Last update: 27/11/2003; 11:29:54.