You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-user@jakarta.apache.org by "Chakravarthy, Srikanth" <Ch...@Misys.com> on 2004/08/02 10:52:08 UTC
Know the runtime class
Hi,
I am creating a cross reference of classes.
If the classes have direct relations then I get all the related classes.
If there is an object of an interface that will be assigned the value of
the implementing class then I am not able to get that class as one of
the references.
For example: class B implements Interface A.
In another class C, I have an object of A. Using reflection, I have
created the object of B and assigned to object of A.
Now, when I run my program to check the cross references for class C, I
do not get class B in the list as it is not directly involved with class
C.
Is there any way to know the instance of the object of A in the class C?
Which API method should I use for this?
Any help is deeply appreciated.
Thanks
Srikanth
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org
Re: Know the runtime class
Posted by Andrew Huntwork <as...@huntwork.net>.
I'm pretty sure that you're describing the pointer aliasing problem,
which is in general undecidable. There are a lot of heuristic and
approximation algorithms that compiler folks use, like Type-Based alias
analysis, which I think comes in 2 flavors, flow sensitive and
flow-insensitive.
basically, don't expect to discover that the concrete type of the field
of type A in C is B. Expect to discover that the concrete type of A is
in a set S which happens to contain B.
hopefully, i'm misinterpreting your question and you're really asking
about something that's solvable. good luck :)
Chakravarthy, Srikanth wrote:
> Hi,
> I am creating a cross reference of classes.
> If the classes have direct relations then I get all the related classes.
> If there is an object of an interface that will be assigned the value of
> the implementing class then I am not able to get that class as one of
> the references.
>
> For example: class B implements Interface A.
> In another class C, I have an object of A. Using reflection, I have
> created the object of B and assigned to object of A.
>
> Now, when I run my program to check the cross references for class C, I
> do not get class B in the list as it is not directly involved with class
> C.
>
> Is there any way to know the instance of the object of A in the class C?
> Which API method should I use for this?
>
> Any help is deeply appreciated.
>
> Thanks
> Srikanth
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: bcel-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org
Re: Know the runtime class
Posted by Dick Eimers <dw...@cs.uu.nl>.
> Is there any way to know the instance of the object of A in the class C?
> Which API method should I use for this?
Don't whether I understand you question, but java.lang.Object.getClass
takes no arguments and returns the class descriptor, i.e. an object
belonging to java.lang.Class, associated with the object on which this
method is invoked.
A side-note; Have you thought of the problems you are about to run into
considering local variables.. I mean fields can be accessed easily and
utilizing the java.lang.reflection and getClass can be used to find out
the runtime class of a value, but object references that are somewhere
on the operand stack; dynamic checks that (un)wind the stack? Problems
assure that you don't generate checks that operate on unitialized
objects..
Have fun..
---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org