[newbie] How to get an IResource of a java file? [message #4494] |
Thu, 24 April 2003 12:04  |
Eclipse User |
|
|
|
Hi again,
is there an easy way of getting an IResource object from any .class file?
For example, I'd like to get an IResource of "java.io.FileReader". Now,
this class is in "rt.jar". How can I get an IResource of it? Or of any
other files?
The large context is that I'd like to get all methods defined in these
files (either class files or java files), and I see no other way than
first determining the resource... But how can I achieve this??
Thanks for your help,
Philipp
|
|
|
Re: [newbie] How to get an IResource of a java file? [message #5541 is a reply to message #4494] |
Fri, 25 April 2003 05:39  |
Eclipse User |
|
|
|
The JAR would be the only IResource you can get your hands onto. However,
the JavaModel allows you to reach inside in a consistent manner.
Create a package fragment root (IPackageFragmentRoot) onto the JAR, then you
can navigate from it to the packages, and to the types you want. Once you
have a type, you can see its methods/fields.
IResource archive = ...; // resource corresponding to rt.jar
IPackageFragmentRoot root = JavaCore.create(archive);
IPackageFragment pkg = root.getPackageFragment("java.io");
IClassFile classFile = pkg.getClassFile("FileReader.class");
IType type = classFile.getType();
IMethod[] methods = type.getMethods();
"Philipp Bouillon" <Philipp.Bouillon@t-online.de> wrote in message
news:b891uh$9sc$1@rogue.oti.com...
> Hi again,
>
> is there an easy way of getting an IResource object from any .class file?
> For example, I'd like to get an IResource of "java.io.FileReader". Now,
> this class is in "rt.jar". How can I get an IResource of it? Or of any
> other files?
>
> The large context is that I'd like to get all methods defined in these
> files (either class files or java files), and I see no other way than
> first determining the resource... But how can I achieve this??
>
> Thanks for your help,
> Philipp
>
|
|
|
Powered by
FUDForum. Page generated in 0.03537 seconds