Note that there are some explanatory texts on larger screens.

plurals
  1. POEclipse plugin development: Discouraged access: The type EclipseStarter is not accessible due to restriction on required library
    text
    copied!<p>I know what "discouraged access" is supposed to mean: you're making use of internal libraries, things that are not in a public API, and you're simply not really supposed to make use of it.</p> <p>Now, as far as I know is the class EclipseStarter in the package "org.eclipse.osgi.util" a part of the public API. I quote: </p> <pre><code>This package specifies API to start the platform. Clients may use the EclipseStarter loader class to start the platform. The EclipseStarter class is the only defined API in this package. </code></pre> <p>Source: <a href="http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fosgi%2Futil%2Fpackage-summary.html" rel="nofollow">http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fosgi%2Futil%2Fpackage-summary.html</a> </p> <p>The details page for the EclipseStarter class states this:</p> <pre><code>Special startup class for the Eclipse Platform. This class cannot be instantiated; all functionality is provided by static methods. Note that the fields on this class are not API. </code></pre> <p>I read: methods are open to be used?</p> <p>My code:</p> <pre><code>import org.eclipse.core.runtime.adaptor.EclipseStarter; </code></pre> <p>This one already gives the warning "Discouraged access: The type EclipseStarter is not accessible due to restriction on required library [path-to-eclipse]\plugins\org.eclipse.osgi_3.7.2.v20120110-1415.jar"</p> <p>The code where I make use of the class:</p> <pre><code>try { EclipseStarter.shutdown(); EclipseStarter.startup(null, null); } catch (Exception e) { e.printStackTrace(); } </code></pre> <p>Warning: Discouraged access: The type EclipseStarter is not accessible due to restriction on required library [path-to-eclipse]\plugins\org.eclipse.osgi_3.7.2.v20120110-1415.jar</p> <p>Warning: Discouraged access: The method shutdown() from the type EclipseStarter is not accessible due to restriction on required library [path-to-eclipse]\plugins\org.eclipse.osgi_3.7.2.v20120110-1415.jar</p> <p>Warning: Discouraged access: The method startup(String[], Runnable) from the type EclipseStarter is not accessible due to restriction on required library [path-to-eclipse]\plugins\org.eclipse.osgi_3.7.2.v20120110-1415.jar</p> <p>I know, I'm calling the startup methode right now with null-values which might not work but I'm just writing code now - not running yet. I don't like the warnings. Either I'm totally wrong on this (and EclipseStarter is not public), either something in my configuration is wrong...</p> <p>I tried adjusting the classpath so that the plugin dependencies come first (before the internal JRE), but that doesn't work either. The library these warnings are talking about are in the dependencies, not in my JRE. I don't know what else I can try.</p> <p>Either way, bottom line I'm actually searching for a nice way to restart my Eclipse programmatically. The plugin code first installs some extra plugins (no warnings, users have to accept the license agreemenets of all these plugins as well), and then should restart. I had been using <code>PlatformUI.getWorkbench().restart();</code> until now, but that gives me an error upon restarting in the log ("event loop" or something). </p> <p>Anyone that can point me in the right direction? Thanks!</p> <hr> <p><strong>Edit</strong>: the error that <code>PlatformUI.getWorkbench().restart()</code> gives me is the following:</p> <pre><code>eclipse.buildId=M20120208-0800 java.version=1.6.0_43 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=nl_BE Framework arguments: -product org.eclipse.epp.package.rcp.product Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.rcp.product Error Thu Nov 07 12:34:11 CET 2013 Unhandled event loop exception org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:4282) at org.eclipse.swt.SWT.error(SWT.java:4197) at org.eclipse.swt.SWT.error(SWT.java:4168) at org.eclipse.swt.widgets.Widget.error(Widget.java:468) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340) at org.eclipse.swt.widgets.Tree.getItems(Tree.java:3249) at org.eclipse.jface.viewers.TreeViewer.getChildren(TreeViewer.java:171) at org.eclipse.jface.viewers.AbstractTreeViewer.internalCollectExpandedItems(AbstractTreeViewer.java:1588) at org.eclipse.jface.viewers.AbstractTreeViewer.getExpandedElements(AbstractTreeViewer.java:1180) at org.eclipse.ui.internal.dialogs.NewWizardNewPage.storeExpandedCategories(NewWizardNewPage.java:626) at org.eclipse.ui.internal.dialogs.NewWizardNewPage.saveWidgetValues(NewWizardNewPage.java:544) at org.eclipse.ui.internal.dialogs.NewWizardSelectionPage.saveWidgetValues(NewWizardSelectionPage.java:99) at org.eclipse.ui.internal.dialogs.NewWizard.performFinish(NewWizard.java:128) at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:831) at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:432) at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) at org.eclipse.jface.window.Window.runEventLoop(Window.java:825) at org.eclipse.jface.window.Window.open(Window.java:801) at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:257) at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:277) at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293) at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476) at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508) at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169) at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241) at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 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.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) </code></pre> <hr> <p><strong>Edit 2:</strong> I'm pretty sure the above error happens because this piece of code is wrong. How would I have to write the performFinish code so that that error doesn't happen? With <code>asyncExec</code>?</p> <pre><code>@Override public final boolean performFinish() { if (getContainer().getCurrentPage().equals(myLastPage)) { PlatformUI.getWorkbench().restart(); return true; } else { return false; } } </code></pre> <hr> <p><strong>Edit 3:</strong> Well, I changed the performFinish code to use <code>asyncExec</code>, but now I get this error:</p> <pre><code>!ENTRY org.eclipse.ui 4 0 2013-11-07 13:56:21.380 !MESSAGE Unhandled event loop exception !STACK 0 org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed) at org.eclipse.swt.SWT.error(SWT.java:4282) at org.eclipse.swt.SWT.error(SWT.java:4197) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 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.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) Caused by: org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:4282) at org.eclipse.swt.SWT.error(SWT.java:4197) at org.eclipse.swt.SWT.error(SWT.java:4168) at org.eclipse.swt.widgets.Widget.error(Widget.java:468) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340) at org.eclipse.swt.widgets.Text.setText(Text.java:1966) at helper.CustomProgressMonitor$1.run(CustomProgressMonitor.java:64) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) ... 23 more </code></pre> <p>This one returns for like 50 times, so obviously, he's trying to still execute something when the Widget has been disposed.</p> <p>This is the new <code>performFinish</code> code:</p> <pre><code>@Override public final boolean performFinish() { if (getContainer().getCurrentPage().equals(myLastPage)) { Display.getDefault().asyncExec(new Runnable() { public void run() { PlatformUI.getWorkbench().restart(); } }); return true; } else { return false; } } </code></pre> <hr> <p><strong>Just to be complete:</strong> it all works now. There was another class (a helper class) where I didn't check if the Text-widget was disposed before accessing it. Once that solved it all works as a charm. Thanks to greg-449!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload