Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » plug-in loading classes question
plug-in loading classes question [message #448375] Mon, 24 April 2006 11:46 Go to next message
Christian Gesswagner is currently offline Christian GesswagnerFriend
Messages: 34
Registered: July 2009
Member
Hi!

I've got a question which relates to loading classes in different plug-ins:

I've got

"PluginA" with package "a.b.c"
"PluginB" with package "a.b.c"

Both have got a class "Hello" in the package "a.b.c"

==> PluginA.a.b.c.Hello
==> PluginB.a.b.c.Hello

"PluginA.a.b.c.Hello" has a method called "helloWorld"
"PluginB.a.b.c.Hello" has a method called "helloUnderWorld"

Now PluginA is loading first.

When PluginB is calling the method "helloUnderWorld" an exception is thrown:
"noSuchMethodError".

I thought that every plugin has its own classloader. So, why does the
"PluginB.a.b.c.Hello" class not override the class "PluginA.a.b.c.Hello",
thus the method "helloUnderWorld" can be found?

Am I missing something in this context, because how will you guarantee, if
you've 100 plugins and no plugin knows the source of any other, that this
problem will not occure?

Thx, Christian
Re: plug-in loading classes question [message #448426 is a reply to message #448375] Mon, 24 April 2006 13:32 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You would only see that kind of behaviour if plugin B has a dependency
on plugin A.

> I thought that every plugin has its own classloader.
> So, why does the "PluginB.a.b.c.Hello" class not override the class
> "PluginA.a.b.c.Hello", thus the method "helloUnderWorld" can be found?

If B depends on A, I would imagine that the plugin B classloader asks A
first (gets the class back) and doesn't look in it's own plugin.

Later,
PW


Re: plug-in loading classes question [message #448428 is a reply to message #448426] Mon, 24 April 2006 14:25 Go to previous messageGo to next message
Christian Gesswagner is currently offline Christian GesswagnerFriend
Messages: 34
Registered: July 2009
Member
Right, there is a dependency, but how can I tell the plugin to look in its
own classes first?

"Paul Webster" <pwebster@ca.ibm.com> schrieb im Newsbeitrag
news:e2ik23$9mk$1@utils.eclipse.org...
> You would only see that kind of behaviour if plugin B has a dependency
> on plugin A.
>
> > I thought that every plugin has its own classloader.
> > So, why does the "PluginB.a.b.c.Hello" class not override the class
> > "PluginA.a.b.c.Hello", thus the method "helloUnderWorld" can be found?
>
> If B depends on A, I would imagine that the plugin B classloader asks A
> first (gets the class back) and doesn't look in it's own plugin.
>
> Later,
> PW
Re: plug-in loading classes question [message #448431 is a reply to message #448428] Mon, 24 April 2006 14:43 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Christian Gesswagner wrote:
> Right, there is a dependency, but how can I tell the plugin to look in its
> own classes first?

you cannot. That's not the way plugin classloading works, and you can't
fool around with it.

An example of eclipse NLS stuff:

org.eclipse.ui.workbench has the WorkbenchMessages NLS class. It also
defines the messages.properties class, which provides it's basic messages.

Then they use a fragment, hosted off of org.eclipse.ui.workbench, to
provide the messages_de.properties in the same package. Fragments are
sucked into the classpath of the host plugin exactly as if they were
part of the host plugin. Then it can find the language when it's changed.

You can't replace something that's already in the classpath, but you can
add the extra bits.

Later,
PW


Re: plug-in loading classes question [message #448441 is a reply to message #448428] Mon, 24 April 2006 22:20 Go to previous message
Neil Bartlett is currently offline Neil BartlettFriend
Messages: 93
Registered: July 2009
Member
The best and most sensible way to avoid getting both yourself and the
classloader confused is to NOT have two plugins containing classes with
exactly the same class and package name.

Regards
Neil
Previous Topic:Need help regarding RCP
Next Topic:Howto: IAction.AS_RADIO_BUTTON getting the selected item?
Goto Forum:
  


Current Time: Thu Nov 14 04:51:50 GMT 2024

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

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

Back to the top