Repository navigation
Support java 9 - #90
Conversation
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
| String cwd, String[] envVars) throws IOException, IllegalConnectorArgumentsException, VMStartException { | ||
| return DebugUtility.launch(vmManager, mainClass, programArguments, vmArguments, String.join(File.pathSeparator, classPaths), cwd, envVars); | ||
| /** | ||
| * Launch a debuggee in suspend mode. |
There was a problem hiding this comment.
suspend ==> suspended
There was a problem hiding this comment.
Suspend Mode is OK, you can google it, there are many places calling it Suspend Mode.
| arguments.get("options").setValue("-cp \"" + classPaths + "\""); | ||
| options = vmArguments; | ||
| } | ||
| if (StringUtils.isNotBlank(modulePaths)) { |
There was a problem hiding this comment.
Just curious, if the vmArguments already have the --module-path or -cp values, what would happen here?
There was a problem hiding this comment.
It would be overided. We don't claim supporting --classpath in vmArguments.
| options += " --module-path \"" + modulePaths + "\""; | ||
| } | ||
| if (StringUtils.isNotBlank(classPaths)) { | ||
| options += " -cp \"" + classPaths + "\""; |
There was a problem hiding this comment.
Would suggest StringBuilder for options
There was a problem hiding this comment.
For simple string concatenation operation, i would prefer the concatenation because the code is shorter. For loop or large string operations, StringBuilder is preferable.
| arguments.get("main").setValue(mainClass); | ||
| mainClass += " " + programArguments; | ||
| } | ||
| arguments.get("main").setValue(mainClass); |
There was a problem hiding this comment.
Should avoid hard coded string if possible
There was a problem hiding this comment.
fixed.
| sourceProvider.initialize(context.getDebugSession(), options); | ||
| } | ||
|
|
||
| private boolean isEmptyArray(String[] items) { |
There was a problem hiding this comment.
Should use since we already refer this lib.
org.apache.commons.lang3.ArrayUtils.isNotEmpty(testArrayName)
There was a problem hiding this comment.
nice
| || (isEmptyArray(launchArguments.modulePaths) && isEmptyArray(launchArguments.classPaths))) { | ||
| AdapterUtils.setErrorResponse(response, ErrorCode.ARGUMENT_MISSING, | ||
| String.format("Failed to launch debuggee VM. Missing mainClass or classPath options in launch configuration")); | ||
| String.format("Failed to launch debuggee VM. Missing mainClass or modulePaths/classPaths options in launch configuration")); |
There was a problem hiding this comment.
"Failed to launch debuggee VM. Missing mainClass or modulePaths/classPaths options in launch configuration"
==>
"Failed to launch debuggee VM. Missing mainClass or modulePaths/classPaths options in the launch configuration"
There was a problem hiding this comment.
fixed.
| launchArguments.vmArgs, StringUtils.join(launchArguments.classPaths, File.pathSeparator), launchArguments.mainClass, launchArguments.args)); | ||
| IDebugSession debugSession = DebugUtility.launch(vmProvider.getVirtualMachineManager(), launchArguments.mainClass, launchArguments.args, | ||
| launchArguments.vmArgs, Arrays.asList(launchArguments.classPaths), launchArguments.cwd, envVars); | ||
| logger.info("Trying to launch Java Program with options:"); |
There was a problem hiding this comment.
Use StringBuilder to avoid multiple call of logger
There was a problem hiding this comment.
nice.
| IModuleDescription module; | ||
| try { | ||
| module = project.getModuleDescription(); | ||
| } catch (JavaModelException e) { |
There was a problem hiding this comment.
JavaModelException to CoreException to keep consistent with the below code.
| @@ -89,16 +79,29 @@ private static IJavaProject getJavaProjectFromName(String projectName) throws Co | |||
| * CoreException | |||
| */ | |||
| private static List<IJavaProject> getJavaProjectFromType(String typeFullyQualifiedName) throws CoreException { | |||
There was a problem hiding this comment.
Normally, typeFullQualifiedName should be fullyQualifiedTypeName
There was a problem hiding this comment.
fixed.
| throw new IllegalArgumentException("javaProject is null"); | ||
| } | ||
| return JavaRuntime.computeDefaultRuntimeClassPath(javaProject); | ||
| String[][] result = new String[2][]; |
There was a problem hiding this comment.
Suggestion only: Could use org.apache.commons.lang3.tuple/pair for better reading.
There was a problem hiding this comment.
In typescript, tuple is like [10, 11], but in org.apache.commons.lang3.tuple.Pair, tuple is like (10, 11), the serialization/deserialization is not compatile, i would prefer to keep current implementation.
Signed-off-by: Jinbo Wang <jinbwan@microsoft.com>
Support set breakpoint in java 9 source file.
Auto detect the project is modular project or not.
Auto resolve module path from project settings.
Auto resolve main class from module.
Support launch options in java 9. (e.g. --module-path, -m)
Peer PR on vscode side:
microsoft/vscode-java-debug#124