From 00e8ca73c3790c7c8eb9ca937ec0337bb6244115 Mon Sep 17 00:00:00 2001 From: Sebastian Zarnekow Date: Mon, 25 Nov 2019 13:13:22 +0100 Subject: [PATCH 1/2] [#60] Avoid deprecation warnings against newer JDT, support Java9 modules --- .../ui/eclipse/launch/MWELaunchDelegate.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java index 59df2c6df..61387e247 100644 --- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java +++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java @@ -152,7 +152,7 @@ public void launch(final ILaunchConfiguration configuration, final String mode, MWEDebuggerLauncher launcher = new MWEDebuggerLauncher(vm); // classpath - String[] classpath = getClasspath(configuration); + String[][] classpathAndModulepath = getClasspathAndModulepath(configuration); // working dir String workingDirName = null; @@ -183,10 +183,18 @@ public void launch(final ILaunchConfiguration configuration, final String mode, (String) null); // bundle config - VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(wfRunnerClassName, classpath); + VMRunnerConfiguration runnerConfig = new VMRunnerConfiguration(wfRunnerClassName, classpathAndModulepath[0]); runnerConfig.setWorkingDirectory(workingDirName); runnerConfig.setProgramArguments(progArgs.toArray(new String[0])); runnerConfig.setVMArguments(DebugPlugin.parseArguments(vmArgs)); + + if (!JavaRuntime.isModularConfiguration(configuration)) { + // Bootpath + runnerConfig.setBootClassPath(getBootpath(configuration)); + } else { + // module path + runnerConfig.setModulepath(classpathAndModulepath[1]); + } monitor.worked(1); monitor.subTask("launching debugger ..."); From bec8fd0b498ad1d82a3e31c22afb53181e48148c Mon Sep 17 00:00:00 2001 From: Sebastian Zarnekow Date: Fri, 29 Nov 2019 15:07:41 +0100 Subject: [PATCH 2/2] Allow to debug w/ Java9++ --- .../eclipse/launch/MWEDebuggerLauncher.java | 42 ++++++++++++------- .../ui/eclipse/launch/MWELaunchDelegate.java | 15 +++++++ 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWEDebuggerLauncher.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWEDebuggerLauncher.java index c10a8fcad..e84019958 100644 --- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWEDebuggerLauncher.java +++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWEDebuggerLauncher.java @@ -15,8 +15,10 @@ import java.io.IOException; import java.text.DateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -24,6 +26,7 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IProcess; +import org.eclipse.emf.mwe.core.WorkflowRunner; import org.eclipse.emf.mwe.internal.core.debug.communication.Connection; import org.eclipse.emf.mwe.internal.ui.debug.model.DebugTarget; import org.eclipse.emf.mwe.internal.ui.workflow.Activator; @@ -139,22 +142,33 @@ private String[] renderCommandLine(final VMRunnerConfiguration config, final int } } - // classpath - String[] cp = config.getClassPath(); - if (cp.length > 0) { - arguments.add("-classpath"); - StringBuilder cpSb = new StringBuilder(); - for (String cpEntry : cp) { - cpSb.append(cpEntry); - cpSb.append(File.pathSeparator); + String[] mp = config.getModulepath(); + if (mp != null && config.getModuleDescription() != null) { + if (mp.length > 0) { + arguments.add("-p"); + arguments.add(Arrays.stream(mp).collect(Collectors.joining(File.pathSeparator))); } - arguments.add(cpSb.substring(0, cpSb.lastIndexOf(File.pathSeparator))); + String mweModuleDescription = WorkflowRunner.class.getPackage().getName(); + // maybe add --add-reads + + arguments.add("--add-modules"); + arguments.add(config.getModuleDescription()); + + arguments.add("-m"); + arguments.add(mweModuleDescription + "/" + config.getClassToLaunch()); + + } else { + // classpath + String[] cp = config.getClassPath(); + if (cp.length > 0) { + arguments.add("-classpath"); + arguments.add(Arrays.stream(cp).collect(Collectors.joining(File.pathSeparator))); + } + // TODO: ER: make sure that all runtime classes that are provided by extensions (handlers, adapters) are in the class path + // the class to launch + arguments.add(config.getClassToLaunch()); } - // TODO: ER: make sure that all runtime classes that are provided by extensions (handlers, adapters) are in the class path - - // the class to launch - arguments.add(config.getClassToLaunch()); - + // programArgs String[] progArgs = config.getProgramArguments(); for (String element : progArgs) { diff --git a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java index 61387e247..621970d38 100644 --- a/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java +++ b/plugins/org.eclipse.emf.mwe.ui/src/org/eclipse/emf/mwe/internal/ui/eclipse/launch/MWELaunchDelegate.java @@ -40,6 +40,7 @@ import org.eclipse.emf.mwe.internal.ui.debug.model.DebugThread; import org.eclipse.emf.mwe.internal.ui.workflow.Activator; import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IModuleDescription; import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate; import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; import org.eclipse.jdt.launching.IVMInstall; @@ -194,6 +195,20 @@ public void launch(final ILaunchConfiguration configuration, final String mode, } else { // module path runnerConfig.setModulepath(classpathAndModulepath[1]); + try { + // We do need the current project module later on - write it into the module description + IJavaProject proj = JavaRuntime.getJavaProject(configuration); + if (proj != null) { + IModuleDescription module = proj.getModuleDescription(); + String modName = module == null ? null : module.getElementName(); + if (modName != null) { + runnerConfig.setModuleDescription(modName); + } + } + } + catch (CoreException e) { + // Not a java Project so no need to set module description + } } monitor.worked(1);