diff options
author | Johan Compagner | 2019-11-14 12:06:05 +0000 |
---|---|---|
committer | Johan Compagner | 2019-11-14 12:06:05 +0000 |
commit | 59bfb6c9baadc28f51ad4de620b91b628836c38f (patch) | |
tree | ed475225a8fefdbb6a8901c68f885e59def399e4 | |
parent | 6862bac5b2c881540e8ee99020975a89cb997684 (diff) | |
download | rt.equinox.p2-59bfb6c9baadc28f51ad4de620b91b628836c38f.tar.gz rt.equinox.p2-59bfb6c9baadc28f51ad4de620b91b628836c38f.tar.xz rt.equinox.p2-59bfb6c9baadc28f51ad4de620b91b628836c38f.zip |
Bug 551378 - Restarting after p2 touchpoint SetJVMAction doesn't useI20191119-1800I20191119-1250I20191119-1235I20191119-1215I20191119-1155I20191119-0850I20191119-0725I20191119-0510I20191119-0315I20191119-0020I20191118-2230I20191118-1800I20191118-0600I20191117-1800I20191117-0600I20191116-1800I20191116-0600I20191115-1800I20191114-1800
correct/new JVM
adjust the 2 system properties that the Workbench will use to restart
the system
made code nicer with using a string constant that is used to jump over
or to concat
added a message why we ignore the exception
Change-Id: I225a76b78fa38195b3ddf36a7874734ebbc17d5f
Signed-off-by: Johan Compagner <jcompagner@gmail.com>
-rw-r--r-- | bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetJvmAction.java | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetJvmAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetJvmAction.java index 1005ac00c..76612bee7 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetJvmAction.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/SetJvmAction.java @@ -15,6 +15,7 @@ package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions; import java.io.File; +import java.io.IOException; import java.util.Map; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -45,6 +46,9 @@ public class SetJvmAction extends ProvisioningAction { // make a backup - even if it is null getMemento().put(ActionConstants.PARM_PREVIOUS_VALUE, previous == null ? null : previous.getPath()); launcherData.setJvm(jvm); + if (jvm != null) { + adjustWorkbenchSystemProperties(jvm); + } return Status.OK_STATUS; } @@ -57,8 +61,44 @@ public class SetJvmAction extends ProvisioningAction { String previous = (String) getMemento().get(ActionConstants.PARM_PREVIOUS_VALUE); LauncherData launcherData = ((Manipulator) parameters.get(EclipseTouchpoint.PARM_MANIPULATOR)) .getLauncherData(); - launcherData.setJvm(previous == null ? null : new File(previous)); + final File jvm = previous == null ? null : new File(previous); + launcherData.setJvm(jvm); + if (jvm != null) { + adjustWorkbenchSystemProperties(jvm); + } return Status.OK_STATUS; } + private static void adjustWorkbenchSystemProperties(File jvm) { + try { + // set the eclipse.vm system property so the Workbench restart will use this vm + // to restart. + final String fullPath = jvm.getCanonicalPath(); + System.setProperty("eclipse.vm", fullPath); + + // also adjust the -vm property in the eclipse.commands system property so that + // vm is actually used. + String property = System.getProperty("eclipse.commands"); + int index = property.indexOf("-vm"); + if (index != -1) { + final String vmWithLineFeed = "-vm\n"; + // find the next line ending after -vm line. + int index2 = property.indexOf('\n', index + vmWithLineFeed.length()); + if (index2 == -1) { + property = property.substring(0, index) + vmWithLineFeed + fullPath; + } else { + String tmp = property.substring(0, index) + vmWithLineFeed + fullPath; + property = tmp + property.substring(index2); + } + System.setProperty("eclipse.commands", property); + } + + } catch (IOException e) { + // ignore this error, should not really happen for file.getCanonicalPath() which + // should be just installed just fine. + // if this fails for some reason then only the restart wouldn't be using this, + // but it wouldn't block the actual install. + } + } + }
\ No newline at end of file |