Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2018-08-15 16:14:37 -0400
committerRoland Grunberg2018-08-17 14:23:41 -0400
commit373d520d5f1892184be28771f770e1a1f6e94e46 (patch)
tree518b2ce26b9cd8379eb0af3887a0c4bd4763f976
parent8f8d132a5e9b5c56de0a84c82fcb2d86c6660256 (diff)
downloadorg.eclipse.linuxtools-373d520d5f1892184be28771f770e1a1f6e94e46.tar.gz
org.eclipse.linuxtools-373d520d5f1892184be28771f770e1a1f6e94e46.tar.xz
org.eclipse.linuxtools-373d520d5f1892184be28771f770e1a1f6e94e46.zip
Bug 537956 - Add support for Java 9 and above.
- "-classpath" extraction should fail gracefully when argument missing - Add support for module (-m) and module path (-p) arguments - Make ContainerVMInstall inherit AbstractVMInstall as this is required for Java >= 9 support - Preserve ability to debug sessions on all available interfaces (*:port) Change-Id: I52db2e71671d701e09a864da4bda6bb7d8d00865 Reviewed-on: https://git.eclipse.org/r/127467 Tested-by: CI Bot Reviewed-by: Roland Grunberg <rgrunber@redhat.com> (cherry picked from commit d120b6613d2ceb055e808c861ebc67fd798b44b0) Reviewed-on: https://git.eclipse.org/r/127583
-rw-r--r--containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java8
-rw-r--r--containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java2
-rw-r--r--containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/JavaAppInContainerLaunchDelegate.java37
3 files changed, 40 insertions, 7 deletions
diff --git a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java
index 697d2046ae..b1c1fb7dd7 100644
--- a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java
+++ b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMInstall.java
@@ -17,8 +17,8 @@ import java.net.URL;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.IVMInstall2;
+import org.eclipse.jdt.internal.launching.StandardVMType;
+import org.eclipse.jdt.launching.AbstractVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.IVMRunner;
import org.eclipse.jdt.launching.LibraryLocation;
@@ -26,7 +26,7 @@ import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
import org.eclipse.linuxtools.docker.core.IDockerImage;
import org.eclipse.linuxtools.internal.docker.core.DockerConnection;
-public class ContainerVMInstall implements IVMInstall, IVMInstall2 {
+public class ContainerVMInstall extends AbstractVMInstall {
private ILaunchConfiguration config;
private String name;
@@ -36,6 +36,8 @@ public class ContainerVMInstall implements IVMInstall, IVMInstall2 {
private String javaVersion;
public ContainerVMInstall (ILaunchConfiguration cfg, IDockerImage img, int port) {
+ // values are ignored (overriden by getVMInstallType() and getId()
+ super(new StandardVMType(), img.id());
this.config = cfg;
this.image = img;
this.port = port;
diff --git a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java
index de9f12036b..62a5097ce5 100644
--- a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java
+++ b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/ContainerVMRunner.java
@@ -162,7 +162,7 @@ public class ContainerVMRunner extends StandardVMRunner {
private String [] extractClassPathFromCommand (String [] cmd) {
int i = 0;
- while (!"-classpath".equals(cmd[i])) { //$NON-NLS-1$
+ while (i < cmd.length && !"-classpath".equals(cmd[i])) { //$NON-NLS-1$
i++;
}
String [] classPath = (cmd.length > i + 1) ? cmd[i+1].split(UnixFile.pathSeparator) : new String[0];
diff --git a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/JavaAppInContainerLaunchDelegate.java b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/JavaAppInContainerLaunchDelegate.java
index 733ce315ee..30a16d5e25 100644
--- a/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/JavaAppInContainerLaunchDelegate.java
+++ b/containers/org.eclipse.linuxtools.jdt.docker.launcher/src/org/eclipse/linuxtools/jdt/docker/launcher/JavaAppInContainerLaunchDelegate.java
@@ -38,10 +38,13 @@ import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IModuleDescription;
import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
import org.eclipse.jdt.launching.ExecutionArguments;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.VMRunnerConfiguration;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.linuxtools.docker.core.DockerConnectionManager;
@@ -153,12 +156,17 @@ public class JavaAppInContainerLaunchDelegate extends AbstractJavaLaunchConfigur
}
}
+ // Bug 522333 :to be used for modulepath only for 4.7.*
+ String[][] paths = getClasspathAndModulepath(configuration);
+
// Create VM config
VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath);
runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
runConfig.setEnvironment(envp);
List<String> finalVMArgs = new ArrayList<> (Arrays.asList(execArgs.getVMArgumentsArray()));
+
+ // See org.eclipse.jdt.internal.launching.StandardVMDebugger#run()
if (ILaunchManager.DEBUG_MODE.equals(mode)) {
double version = getJavaVersion(conn, img);
if (version < 1.5) {
@@ -173,7 +181,7 @@ public class JavaAppInContainerLaunchDelegate extends AbstractJavaLaunchConfigur
if (version < 1.5) {
finalVMArgs.add("-Xrunjdwp:transport=dt_socket,server=y,address=" + port); //$NON-NLS-1$
} else {
- finalVMArgs.add("-agentlib:jdwp=transport=dt_socket,server=y,address=" + port); //$NON-NLS-1$
+ finalVMArgs.add("-agentlib:jdwp=transport=dt_socket,server=y,address=*:" + port); //$NON-NLS-1$
}
}
@@ -181,8 +189,31 @@ public class JavaAppInContainerLaunchDelegate extends AbstractJavaLaunchConfigur
runConfig.setWorkingDirectory(workingDirName);
runConfig.setVMSpecificAttributesMap(vmAttributesMap);
- // Bootpath
- runConfig.setBootClassPath(getBootpath(configuration));
+ try {
+ IJavaProject proj = JavaRuntime.getJavaProject(configuration);
+ if (proj != null) {
+ IModuleDescription module = proj == null ? null : proj.getModuleDescription();
+ String modName = module == null ? null : module.getElementName();
+ if (modName != null) {
+ runConfig.setModuleDescription(modName);
+ }
+ }
+ } catch (CoreException e) {
+ // Not a java Project so no need to set module description
+ }
+
+ if (!JavaRuntime.isModularConfiguration(configuration)) {
+ // Bootpath
+ runConfig.setBootClassPath(getBootpath(configuration));
+ } else {
+ // module path
+ runConfig.setModulepath(paths[1]);
+ if (!configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_MODULE_CLI_OPTIONS, true)) {
+ runConfig.setOverrideDependencies(configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MODULE_CLI_OPTIONS, "")); //$NON-NLS-1$
+ } else {
+ runConfig.setOverrideDependencies(getModuleCLIOptions(configuration));
+ }
+ }
// check for cancellation
if (monitor.isCanceled()) {

Back to the top