Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Package level access to another plugin
Package level access to another plugin [message #295821] Thu, 08 December 2005 08:44 Go to next message
Eclipse UserFriend
I'm in a bit of a bind and I'm hoping someone can help me out. I'll say up front that this is a hack but I really need it at the moment. I need to be able to call the function CCombo.dropDown(boolean) from a plugin that is not the SWT plugin. This method is declared as a package level method. I can write a method to do this and it works fine when running as a SWT application but once I put the Eclipse runtime in the mix I receive IllegalAccessErrors. I understand why this is discouraged and I wouldn't do this for a long term solution. I've also already logged an enhancement request (https://bugs.eclipse.org/bugs/show_bug.cgi?id=119057) to hopefully make this method public or protected. Is there any way to do this without building my own version of the SWT plugin?

Below is the exception that I'm receiving. I'm running this from an abbot JUnit.

java.lang.IllegalAccessError: tried to access method org.eclipse.swt.custom.CCombo.dropDown(Z)V from class org.eclipse.swt.custom.CComboUtil
at org.eclipse.swt.custom.CComboUtil.dropDown(CComboUtil.java:5 )
at CComboAbbotTest$1.widgetSelected(CComboAbbotTest.java:31)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:90)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3080)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2713)
at CComboAbbotTest.testRun(CComboAbbotTest.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:344)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r.main(RemotePluginTestRunner.java:57)
at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.r un(UITestApplication.java:99)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:123)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3057)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2716)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1699)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:367)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:143)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:103)
at org.eclipse.pde.internal.junit.runtime.UITestApplication.run (UITestApplication.java:39)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:226)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
at org.eclipse.core.launcher.Main.run(Main.java:973)
at org.eclipse.core.launcher.Main.main(Main.java:948)
Re: Package level access to another plugin [message #295827 is a reply to message #295821] Thu, 08 December 2005 09:43 Go to previous messageGo to next message
Eclipse UserFriend
Brad Reynolds wrote:
> This method is declared as a package level method. I can write a
> method to do this and it works fine when running as a SWT application
> but once I put the Eclipse runtime in the mix I receive
> IllegalAccessErrors.

On solution might be to package your code into a fragment to
org.eclipse.swt. Fragments have access to package visible
classes/methods of the host plug-in.

Another option might be to play with Buddy classloading in the
MANIFEST.MF files (like the SWT fragments do).

Cu, Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Package level access to another plugin [message #295855 is a reply to message #295827] Thu, 08 December 2005 17:01 Go to previous messageGo to next message
Eclipse UserFriend
Thank you for the suggestions. I tried creating a fragment and ran into some issues. I set the host plugin as org.eclipse.swt but in my fragment I can't see any of the classes exported by org.eclipse.swt. Can a fragment see the exported API of another fragment when they share the same host plugin?
Re: Package level access to another plugin [message #295881 is a reply to message #295855] Fri, 09 December 2005 11:27 Go to previous message
Eclipse UserFriend
For completeness I thought I'd post the solution. I'm using the suggested mechanism of creating a fragment for SWT but I have to use reflection in order to manipulate the CCombo. The problem is that a fragment can't see API exposed by another fragment when they specify the same host. The decision for this and reasoning why can be found in bug 85031 on comments 17 and 18 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=85031#c17).
Previous Topic:Enter Key in Save Resources Dialogue
Next Topic:[HowTo] programmatically set a non-empty Selection that will be accepted by the ISelectionProvider?
Goto Forum:
  


Current Time: Fri May 09 14:14:47 EDT 2025

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

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

Back to the top