ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: class casting betwn build xmls
Date Tue, 11 Jul 2006 21:04:28 GMT
shreedharn@amiindia.co.in wrote:
> Hi All,
> 
> I have a problem with class casting. Here is the scenario -
> 
> I have an ant custom task say "mycustomA". Inside the execute method, I
> create a custom obj say "customobj" of a user-defined type. I store the
> "customobj" in the project reference using
> getProject().addReference("key",customobj).
> 
> I using mycustomA in a "build.xml". After invoking the task mycustomA I
> use ant task <ant> with inheritRefs=true to call another
> "buildsecond.xml"  Inside buildsecond.xml, I use a custom task say
> "mycustomB" which tries to get the reference of the customobj using the
> method getProject().getReference("key"). When I try to cast to the
> "customobj" type I get a classcast exception.
> 
> But customobj.getClass().getName() prints the exact type of customobj.
> But the instance of operator fails saying false. Is this any issue with
> class loader ?
> 

Unless you declare the two custom tasks in the same classloader, they 
are going to be be in separate classloaders, so not able to share datatypes.

workarounds
  -declare them in the same classloader, by giving every taskdef/typedef 
the same loaderref value
  -serialize the object and save to the project that way.
I'd go for the first option


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


Mime
View raw message