File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Help reqd in reflection API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help reqd in reflection API" Watch "Help reqd in reflection API" New topic
Author

Help reqd in reflection API

Devesh H Rao
Ranch Hand

Joined: Feb 09, 2002
Posts: 687

Hi,
I have the following two classes....
public class ParentClass{
}
public class ChildClass extends ParentClass{
}
Some code in some main method in some class

// code
Class c = Class.forName("ChildClass");
Class parentC = c.??? ; //
// Code end
I need to get the class inherited by the child class ie the Parentclass using reflection can anyone help me out on this.
c.getSuperClass dosent work....
Thanks.
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
It is getSuperclass() not getSuperClass() (Note the case).


Mani
Quaerendo Invenietis
Devesh H Rao
Ranch Hand

Joined: Feb 09, 2002
Posts: 687

Originally posted by Mani Ram:
It is getSuperclass() not getSuperClass() (Note the case).

It was just a typo error while posting message..
i tried the getSuperclass() which returned java.lang.Class which is not what i want.
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Originally posted by Devesh H Rao:

i tried the getSuperclass() which returned java.lang.Class which is not what i want.

How you made sure that it returned java.lang.Class. Here is what I did



I get the output as class ParentClass
Devesh H Rao
Ranch Hand

Joined: Feb 09, 2002
Posts: 687

Originally posted by Mani Ram:
I get the output as [b]class ParentClas

Instead of parentClass.getName() I did parentClass.getClass() no doubt i got java.lang.Class.
Thanks mani...
They say stupidty has no limits i think i just raised the benchmark
[ February 19, 2004: Message edited by: Devesh H Rao ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help reqd in reflection API