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
|