Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » instanceof doesn't work in plugin
instanceof doesn't work in plugin [message #288592] Wed, 20 July 2005 03:40 Go to next message
Eclipse UserFriend
Originally posted by: jongn.xxxxx.nl

I'm trying to learn how to create plugins in Eclipse but seem to have
hit a snag. I've Googled for this problem but couldn't find others with
this problem so I must do something wrong that is very obvious. Perhaps
any of you can tell me what?

I created the HelloworldPlugin example from the wizard. Going into the
SampleAction.selectionChanged(IAction action, ISelection selection)
method, I added some print lines that show the following result:

selection=class org.eclipse.jface.text.TextSelection
instanceof org.eclipse.jface.text.ITextSelection? false
instanceof org.eclipse.jface.text. TextSelection? false

Now I understand why the instanceof fails, it's because of different
classloaders:

this.classLoader=org.eclipse.core.runtime.adaptor.EclipseClassLoader@12438f1
selection.classLoader=org.eclipse.core.runtime.adaptor.EclipseClassLoader@1f436f5

Now what I don't understand is how I can use instanceof or casting when
the arguments of methods called are created from a different classloaded
from the plugin classloader.
Re: instanceof doesn't work in plugin [message #288598 is a reply to message #288592] Wed, 20 July 2005 03:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.megert.gmx.net

Nick de Jong wrote:

> I'm trying to learn how to create plugins in Eclipse but seem to have
> hit a snag. I've Googled for this problem but couldn't find others
> with this problem so I must do something wrong that is very obvious.
> Perhaps any of you can tell me what?
>
> I created the HelloworldPlugin example from the wizard. Going into the
> SampleAction.selectionChanged(IAction action, ISelection selection)
> method, I added some print lines that show the following result:
>
> selection=class org.eclipse.jface.text.TextSelection
> instanceof org.eclipse.jface.text.ITextSelection? false
> instanceof org.eclipse.jface.text. TextSelection? false
>
> Now I understand why the instanceof fails, it's because of different
> classloaders:
>
> this.classLoader=org.eclipse.core.runtime.adaptor.EclipseClassLoader@12438f1
>
> selection.classLoader=org.eclipse.core.runtime.adaptor.EclipseClassLoader@1f436f5
>
>
> Now what I don't understand is how I can use instanceof or casting
> when the arguments of methods called are created from a different
> classloaded from the plugin classloader.


This works for me. You probably forgot to add 'org.eclipse.jface.text'
to the manifest.mf (or plugin.xml).

Dani
Re: instanceof doesn't work in plugin [message #288608 is a reply to message #288598] Wed, 20 July 2005 04:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jongn.xxxxx.nl

Daniel Megert wrote:

>> Now what I don't understand is how I can use instanceof or casting
>> when the arguments of methods called are created from a different
>> classloaded from the plugin classloader.
>
> This works for me. You probably forgot to add 'org.eclipse.jface.text'
> to the manifest.mf (or plugin.xml).

Ah yes, that was it. I wondered why this text plugin was the only one
outside the "Plug-in Dependencies" list. I just had to add it to
the 'dependencies' tab (although the list of plug-ins in this tab is
smaller then the "Plug-in Dependencies" list so some plug-ins must be
coming from some other list).

But I can continue again.

Thanks a lot!
Re: instanceof doesn't work in plugin [message #288632 is a reply to message #288608] Wed, 20 July 2005 10:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

The "Plugin Dependencies" list in the package explorer shows you the
plugins you directly depend on and any re-exported ones that those
dependencies re-export, and so on.

The "dependencies" tab in your manifest editor only shows the ones that
you directly depend on.

I'm surprised that since it was not in your dependency list, nor was it
one of the reexported ones, that you didn't get a compile error, or at
least a warning.

--
Thanks,
Rich Kulp
Re: instanceof doesn't work in plugin [message #288676 is a reply to message #288632] Thu, 21 July 2005 03:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jongn.xxxxx.nl

Rich Kulp wrote:

> The "Plugin Dependencies" list in the package explorer shows you the
> plugins you directly depend on and any re-exported ones that those
> dependencies re-export, and so on.
>
> The "dependencies" tab in your manifest editor only shows the ones that
> you directly depend on.
>
> I'm surprised that since it was not in your dependency list, nor was it
> one of the reexported ones, that you didn't get a compile error, or at
> least a warning.
>

I went to the project properties -> Java Build Path and added the plugin
there, like I was used to in other (non-plugin) projects. I noticed that
I could not add it to the 'Plug-in Dependencies' since that was
automatically updated' (I didn't agree to that:). That I had to add the
plug-in dependencies somewhere else I found a bit counter-intuitive but
now I know, it works just as well.
Re: instanceof doesn't work in plugin [message #288693 is a reply to message #288676] Thu, 21 July 2005 11:13 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

When working with plugins you must always update the
plugin.xml/Manifest.MF. Do not update the build path. That will almost
always give you problems. If you add to the build path, it is then not
in the manifest and then when you try to run this outside of development
it will not work.

> I went to the project properties -> Java Build Path and added the plugin
> there, like I was used to in other (non-plugin) projects. I noticed that
> I could not add it to the 'Plug-in Dependencies' since that was
> automatically updated' (I didn't agree to that:). That I had to add the
> plug-in dependencies somewhere else I found a bit counter-intuitive but
> now I know, it works just as well.

--
Thanks,
Rich Kulp
Previous Topic:Eclipe 3.1 & Project Import from 3.0 Problem
Next Topic:Update Site Builder Has Hidden Cache That Causes Problems
Goto Forum:
  


Current Time: Fri Jul 25 14:48:47 EDT 2025

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

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

Back to the top