Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Compagner2019-11-14 07:06:05 -0500
committerJohan Compagner2019-11-14 07:06:05 -0500
commit59bfb6c9baadc28f51ad4de620b91b628836c38f (patch)
treeed475225a8fefdbb6a8901c68f885e59def399e4
parent6862bac5b2c881540e8ee99020975a89cb997684 (diff)
downloadrt.equinox.p2-59bfb6c9baadc28f51ad4de620b91b628836c38f.tar.gz
rt.equinox.p2-59bfb6c9baadc28f51ad4de620b91b628836c38f.tar.xz
rt.equinox.p2-59bfb6c9baadc28f51ad4de620b91b628836c38f.zip
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.java42
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

Back to the top