Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » IJavaProject instances classloader
IJavaProject instances classloader [message #255172] Tue, 22 July 2008 21:09 Go to next message
Raster R is currently offline Raster RFriend
Messages: 77
Registered: July 2009
Member
How can I get access to a IJavaProject instances classloader so that I can
load some classes contained in that project's classpath.
Re: IJavaProject instances classloader [message #255201 is a reply to message #255172] Wed, 23 July 2008 20:45 Go to previous messageGo to next message
Raster R is currently offline Raster RFriend
Messages: 77
Registered: July 2009
Member
I have a popup menu using <extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.jdt.core.IJavaProject">

My action implements IObjectActionDelegate and I am able to obtain the
IJavaProject object corresponding to the java projec i select in the
workspace.

I am also able to drill down and locate each ICompilationUnit instance.

From here I can obtain the class names of the classes. For some reason my
plugin needs to obtain the java.lang.Class object of the class. How can I
do this?
Re: IJavaProject instances classloader [message #255235 is a reply to message #255201] Thu, 24 July 2008 13:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Basically you can't. Classes in the project are not loaded into Eclipse.

What do you need from the Class object? You should be able to get just
about everything you need from JDT instead.
>
> From here I can obtain the class names of the classes. For some reason
> my plugin needs to obtain the java.lang.Class object of the class. How
> can I do this?
>

--
Thanks,
Rich Kulp
Re: IJavaProject instances classloader [message #255326 is a reply to message #255235] Tue, 29 July 2008 16:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: crscca.yahoo.com

The only thing I want is get the Class object and pass it to some third
party code that uses Class object references and generates some other code
using the Class object.
This is really needed by me.


If this is not possible I will probably be forced to spawn a seperate
Runtime process with Java being launched etc.
Re: IJavaProject instances classloader [message #255330 is a reply to message #255326] Tue, 29 July 2008 16:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Spawning is the best bet. That is safest.

Raster wrote:
>
> The only thing I want is get the Class object and pass it to some third
> party code that uses Class object references and generates some other
> code using the Class object.
> This is really needed by me.
>
>
> If this is not possible I will probably be forced to spawn a seperate
> Runtime process with Java being launched etc.
>

--
Thanks,
Rich Kulp
Re: IJavaProject instances classloader [message #255334 is a reply to message #255326] Wed, 30 July 2008 01:58 Go to previous message
Walter Harley is currently offline Walter HarleyFriend
Messages: 847
Registered: July 2009
Senior Member
Raster wrote:
>
> The only thing I want is get the Class object and pass it to some third
> party code that uses Class object references and generates some other
> code using the Class object.

You could create an URLClassLoader based on the bin directory that
corresponds to the source folder in question, and use it to load the
class.

However, I'll warn you in advance that it's hard to get those
classloaders to go away, and until the classloader is garbage collected
that .class file will be locked and you won't be able to do any more
builds. This is one of the several reasons why Rich is right that
spawning a new VM is the best answer if you have to load code from a
workspace.
Previous Topic:ITypeParameter is not an IAnnotatable
Next Topic:IJavaProject.setRawClasspath deadlock
Goto Forum:
  


Current Time: Fri Apr 26 09:45:04 GMT 2024

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

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

Back to the top