Partial fix for Bug 50577 - improve feedback on startup failure
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
index 9208dbc..5af97b3 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -328,7 +328,7 @@
/**
- * Returns a log for the given plugin or <code>null</code> if none exists.
+ * Returns a log for the given plugin. Creates a new one if needed.
*/
public ILog getLog(Bundle bundle) {
ILog result = (ILog) logs.get(bundle);
@@ -381,6 +381,12 @@
}
code.handleException(e);
}
+ /**
+ * @return whether platform log writer has already been registered
+ */
+ public boolean hasLogWriter() {
+ return platformLog != null && logListeners.contains(platformLog);
+ }
public IExtensionRegistry getRegistry() {
return registry;
@@ -460,7 +466,7 @@
* @see BootLoader
*/
- public void start(BundleContext context) throws Exception {
+ public void start(BundleContext context) {
this.context = context;
// TODO figure out how to do the splash. This really should be something that is in the OSGi implementation
endOfInitializationHandler = getSplashHandler();
@@ -478,7 +484,7 @@
addLogListener(consoleLog);
}
platformRegistration = context.registerService(IPlatform.class.getName(), this, null);
- }
+ }
/**
*
*/
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java
index bdebfb7..cb454f2 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java
@@ -38,15 +38,30 @@
}
public void start(BundleContext context) throws Exception {
- PlatformActivator.context = context;
- acquireInfoService();
- acquireURLConverterService();
- startInternalPlatform();
- startRegistry(context);
- installPlatformURLSupport();
- registerApplicationService();
- InternalPlatform.getDefault().setRuntimeInstance(this);
- super.start(context);
+ try {
+ PlatformActivator.context = context;
+ acquireInfoService();
+ acquireURLConverterService();
+ startInternalPlatform();
+ startRegistry(context);
+ installPlatformURLSupport();
+ registerApplicationService();
+ InternalPlatform.getDefault().setRuntimeInstance(this);
+ super.start(context);
+ } catch (Exception e) {
+ // need to show any exception that happened, otherwise the platform will not start
+ String message = Policy.bind("meta.platform", e.toString());
+ if (InternalPlatform.getDefault().hasLogWriter()) {
+ IStatus status = new Status(IStatus.ERROR, IPlatform.PI_RUNTIME, IPlatform.INTERNAL_ERROR, message, e); //$NON-NLS-1$
+ InternalPlatform.getDefault().log(status);
+ } else {
+ // if we cannot count on a log file, let's hope the user has a console open
+ System.err.println(message);
+ e.printStackTrace();
+ }
+ // let the exception interrupt the activation of the platform bundle
+ throw e;
+ }
}
/**
@@ -137,7 +152,7 @@
InternalPlatform.urlConverter = (URLConverter) context.getService(urlServiceReference);
}
- private void startInternalPlatform() throws Exception {
+ private void startInternalPlatform() {
InternalPlatform.getDefault().start(context);
}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/messages.properties b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/messages.properties
index 1074eff..ea4bd6d 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/messages.properties
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/messages.properties
@@ -96,6 +96,7 @@
in deleting the old lock file. If no other platform instances are running, delete the \n\
lock file ({0}) and try starting the platform again.
meta.notDir = Specified platform location \"{0}\" is not a directory.
+meta.platform = Unexpected error starting the platform.
meta.pluginProblems = Problems occurred when invoking code from plug-in: \"{0}\".
meta.readonly = The platform metadata area could not be written: {0}. By default the platform writes its content\nunder the current working directory when the platform is launched. Use the -data parameter to\nspecify a different content area for the platform.
meta.readPlatformMeta = Could not read platform metadata: {0}.