Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,23 @@ class JavaLanguageClient extends AutoLanguageClient {
})
.then(() => this.getOrCreateDataDir(projectPath))
.then(dataDir => {
const args = [
const args = []
if (javaVersion >= 9) {
args.push(
'--add-modules=ALL-SYSTEM',
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED'
)
}

const extraArgs = this.parseArgs(atom.config.get('ide-java.virtualMachine.extraArgs'))
args.push(...extraArgs)

args.push(
'-jar', path.join(serverHome, serverLauncher),
'-configuration', path.join(serverHome, `config_${config}`),
'-data', dataDir
]
if (javaVersion >= 9) {
args.push('--add-modules=ALL-SYSTEM');
args.push('--add-opens', 'java.base/java.util=ALL-UNNAMED');
args.push('--add-opens', 'java.base/java.lang=ALL-UNNAMED');
}
)

this.logger.debug(`starting "${command} ${args.join(' ')}"`)
const childProcess = cp.spawn(command, args, { cwd: serverHome })
Expand Down Expand Up @@ -253,6 +260,17 @@ class JavaLanguageClient extends AutoLanguageClient {
})
})
}

parseArgs(argsLine) {
if (!argsLine) return []

// Split the args into an array based on whitespace outside of double-quotes
const args = argsLine.match(/(?:[^\s"]+|"[^"]*")+/g)
if (args === null) return []

// Remove double quotes
return args.map(arg => arg.replace(/(\\)?"/g, (a, b) => a ? b : '').replace(/(\\)"/g, '"'))
}
}

module.exports = new JavaLanguageClient()
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,20 @@
"default": "",
"description": "Absolute path to Java 8 or later home folder used to launch the Java language server."
},
"errors": {
"virtualMachine": {
"order": 20,
"type": "object",
"properties": {
"extraArgs": {
"type": "string",
"default": "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication",
"description": "Extra arguments passed to the Java VM when launching the Java Language Server. Eg. use `-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication` to bypass class verification, increase the heap size to 1GB and enable String deduplication with the G1 Garbage collector."
}
}
},
"errors": {
"order": 30,
"type": "object",
"title": "Warnings and Errors",
"properties": {
"incompleteClasspathSeverity": {
Expand All @@ -33,7 +44,7 @@
"error"
],
"default": "warning",
"description": "Specifies the severity of the message when the classpath is incomplete for a Java file."
"description": "Severity of the message when the classpath is incomplete for a Java file."
}
}
}
Expand Down