yes, but not really efficiently. You just have to use a graph search algorithm like dfs or bfs to walk through the superclases and interfaces of each class in the classpath. You can get the interface and superclass names using ClassGen.getInterfaceNames and ClassGen.getSuperclassName.

btw, if you happen to work for misys in tucson, feel free to drop by the Java Users Group next week (tucson-jug.org). I and probably one other person who will be there will be glad to chat about bytecode editing.

Chakravarthy, Srikanth wrote:
Thanks for the reply.
Actually my problem will be solved even if I get the set S as you have
mentioned. But how do I get the set S?

Is it possible to know the implementors of a given interface using
JavaClass? Or should I use a different API? Then using this list I can
check if the object of A is an instance of B.

Thanks,
Srikanth

-----Original Message-----
From: Andrew Huntwork [mailto:[EMAIL PROTECTED] Sent: 02 August 2004 15:40
To: BCEL Users List
Subject: Re: Know the runtime class


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to