ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wohlgemuth <berlinguyi...@gmail.com>
Subject Re: weird problem with Class instanceOf
Date Wed, 09 Aug 2006 03:38:45 GMT
I give it a try first tomorrow morning, but I'm acually quite shure
that this is not the case, cause I tried already different names for
the classes to check this.

thanks for your help and I will see it tomorrow morning. How does the
internal system with the references work anyway? Cause I was not able
to find any documentation online and after reading throw the ant code
did'nt help me very much.

/gert



On 8/8/06, Stephen McConnell <mcconnell@dpml.net> wrote:
>
>
> > -----Original Message-----
> > From: wohlgemuth [mailto:berlinguyinca@gmail.com]
> > Sent: Wednesday, 9 August 2006 11:20 AM
> > To: user@ant.apache.org
> > Subject: weird problem with Class instanceOf
> >
> > hi,
> >
> > at first I work since a long time with ant and wrote arround
> > 50 ant tasks sofar, I thought I know what I do...
> > ...I was wrong
> >
> > anyway thats my problem:
> >
> > I have 3 classes
> >
> > 1. ClusterInitialzieTask, parent class:Task
> >
> > -> used to intialize a cluster and contains objects of type 2. or 3.
> >
> > 2. ClusterParameter, parent class: ProjectComponent
> >
> > -> a configuration parameter
> >
> > 3. Configuration, parent class: DataType
> >
> > -> my configuration containing objects of type 2.
> >
> > now I want to access the object configuration over a refrence
> >
> > <config id="conf">
> >  <parameter name="username" value="my name" />
> > </config>
> >
> >
> > <initialize factory="tada">
> >  <config refid="conf"/>
> > </initialize>
> >
> > and always get:
> >
> > conf doesn't denote a config
> >       at
> > org.apache.tools.ant.types.DataType.getCheckedRef(DataType.java:156)
> >       at
> > edu.ucdavis.genomics.metabolomics.binbase.cluster.ant.Configur
> > ation.getContent(Configuration.java:68)
> >       at
> > edu.ucdavis.genomics.metabolomics.binbase.cluster.ant.ClusterI
> > nitializeTask.getProperties(ClusterInitializeTask.java:122)
> >
> > method where the call happens:
> >
> > Object o = this.getCheckedRef(Configuration.class, "config");
> >
> >
> > when I access the refrence object direclty in the setRefId
> > method and make a simple System.err:
> >
> > System.err.println(reference.getReferencedObject() instanceof
> > edu.ucdavis.genomics.metabolomics.binbase.cluster.ant.Configuration);
> >
> > System.err.println(reference.getReferencedObject().getClass());
> >
> > i become an output like this:
> >
> > [initialize] false
> > [initialize] class
> > edu.ucdavis.genomics.metabolomics.binbase.cluster.ant.Configuration
> >
> > I know they are both from the same instance I just don't know
> > why my instanceof gives me a "false" and not a "true".
>
> Sounds like you have a cloassloader chain issue.  I'm guessing that the
> Configuration class that your casting to is not the same class as the
> Configuration class held as a reference.  You confirm this by listing the
> system identity hashcode for both, e.g:
>
>   Class local = Configuration.class;
>   Class unknown = reference.getReferencedObject().getClass();
>   System.err.println( "LOCAL: " + System.identityHashCode( local ) );
>   System.err.println( "UNKNOWN: " + System.identityHashCode( unknown ) );
>
> The values returned for the identity hashcode will probably be different
> which is why your instanceof test is failing.  Assuming we are talking about
> separate instances it would be handy to find out where the respective
> classes are located.
>
>   URL localURL = local.getProtectionDomain().getCodeSource().getLocation();
>   URL unknownURL =
> unknown.getProtectionDomain().getCodeSource().getLocation();
>   System.err.println( "LOCAL-URL: " + localURL );
>   System.err.println( "UNKNOWN-URL: " + unknownURL );
>
> Assuming that the two locations are different you will need to figure out
> why the same class exists in two different locations (i.e. different
> classloaders where the common class is not actually available in a mutually
> accessible classloader).
>
> /Steve.
>
>
> >
> > does anybody has an idea? I can also provide the sourcecode
> > if requested.
> >
> > thx for your help,
> >
> > g.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For
> > additional commands, e-mail: user-help@ant.apache.org
> >
>


-- 
--------------------------------------------------------------------
http://fiehnlab.ucdavis.edu/staff/wohlgemuth

work:    wohlgemuth@ucdavis.edu
phone:   530 754 7113

private: wohlgemuth@mindcrime-ilab.de
phone:    530 220 3728

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


Mime
View raw message