Locate all super/implementations for a class

W

Wojtek

It is trivial to test if a class implements/extends a class, if you
already know the name of that class.

But how do you find all the super/interfaces which a given class
extends/implements?

What I am trying to do is scan a Map which contains all my DB table
classes (one class per table). I want to be able to list all the
super/interfaces:

TableClass Super Implements
-------------------------------------
Person
Data SuperData
Data2 DataImp
DataImp2

and so on.
 
R

Roedy Green

It is trivial to test if a class implements/extends a class, if you
already know the name of that class.

You could waddle through all the elements of a jar collecting the
inheritance info, then using it to build a tree.

See http://mindprod.com/jgloss/jasm.html
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Change will not come if we wait for some other person or some other time. We are the ones we’ve been waiting for. We are the change that we seek."
~ Barack Obama (born: 1961-08-04 age: 48)
 
W

Wojtek

markspace wrote :
More generally, this is called Reflection. More info from Sun:

I am on the West coast of Canada, it has been brutally hot the past
couple of weeks, I am not getting much sleep, and my brain has gone
dead.

Yes, you are right. I do not normally program in that space and had
forgotten about it.

Yawn...
 
M

markspace

Wojtek said:
I am on the West coast of Canada, it has been brutally hot the past
couple of weeks, I am not getting much sleep, and my brain has gone dead.

Yes, you are right. I do not normally program in that space and had
forgotten about it.


I was wondering if that intro was going anywhere. No worries, the Java
API is huge, we all need a little nudge in the right direction sometimes.
 
R

Roedy Green

I am on the West coast of Canada, it has been brutally hot the past
couple of weeks, I am not getting much sleep, and my brain has gone
dead.

Yes, you are right. I do not normally program in that space and had
forgotten about it.

The simple reflection approach presumes the classes of interest all
loaded. Parsing class files in jar files lets you get at unloaded
classes, and sets of classes that would be too big to load.

I remember visiting St. Louis in the early 70s and being astounded
that people could survive outdoors outside of air conditioned
buildings. Now my part of the world too (Western Canada) is setting
record temperatures along with raging forest fires. We simply are not
used to it. Fans and air conditioners are doing a roaring business.
The global warming skeptics of course ignore this anecdotal support
for rising average global temperature.

--
Roedy Green Canadian Mind Products
http://mindprod.com

"Let us pray it is not so, or if it is, that it will not become widely known."
~ Wife of the Bishop of Exeter on hearing of Darwin's theory of the common descent of humans and apes.
 
W

Wojtek

Roedy Green wrote :
The global warming skeptics of course ignore this anecdotal support
for rising average global temperature.

Sigh.

I think the long and cold winter we just had balances this out quite
well. And there is mounting evidence that all of this is cyclical and
would have happened anyway. Plus, the hottest year this time around was
1998 and there is now a slight cooling trend. And we are still cooler
than the middle ages when the last up cycle was (which the IPCC removed
from their reports), and a lot cooler than about 3K years ago,
nevermind when the dinosaurs roamed Alberta.

Anyway, I will not debate this here as I am sure the other people do
not want to wade through the posts.

Climate is what you expect. Weather is what you get.
 
L

Lew

Roedy Green wrote :


Sigh.

I think the long and cold winter we just had balances this out quite
well. And there is mounting evidence that all of this is cyclical and
would have happened anyway. Plus, the hottest year this time around was
1998 and there is now a slight cooling trend. And we are still cooler
than the middle ages when the last up cycle was (which the IPCC removed
from their reports), and a lot cooler than about 3K years ago,
nevermind when the dinosaurs roamed Alberta.

Anyway, I will not debate this here as I am sure the other people do
not want to wade through the posts.

Climate is what you expect. Weather is what you get.

Read
<http://home.comcast.net/~berkowitz5419/Docs/Gaia.htm>
on why it's a good thing mankind releases CO2 back into the atmosphere
from which it has been robbed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top