Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » [newbie] How to get an IResource of a java file?
[newbie] How to get an IResource of a java file? [message #4494] Thu, 24 April 2003 12:04 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:How do I set the font for a text viewer?
Next Topic:Shared working copies
Goto Forum:
  


Current Time: Mon May 12 21:32:00 EDT 2025

Powered by FUDForum. Page generated in 0.03537 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top