@@ -73,6 +73,12 @@ deduplication with the G1 Garbage collector"
73
73
:risky t
74
74
:type '(repeat string))
75
75
76
+ (defcustom lsp-java-9-args '(" --add-modules=ALL-SYSTEM" " --add-opens java.base/java.util=ALL-UNNAMED" " --add-opens java.base/java.lang=ALL-UNNAMED" )
77
+ " Specifies arguments specific to java 9 and later."
78
+ :group 'lsp-java
79
+ :risky t
80
+ :type '(repeat string))
81
+
76
82
(defcustom lsp-java-incomplete-classpath 'warning
77
83
" Specifies the severity of the message when the classpath is incomplete for a Java file."
78
84
:group 'lsp-java
@@ -308,11 +314,25 @@ FULL specify whether full or incremental build will be performed."
308
314
(unless (file-directory-p path)
309
315
(make-directory path)))
310
316
317
+ (defun lsp-java--get-java-version ()
318
+ " Retrieve the java version from shell command."
319
+ (let* ((java-version-output (shell-command-to-string (concat lsp-java-java-path " -version" )))
320
+ (version-string (nth 2 (split-string java-version-output))))
321
+ (string-to-number (replace-regexp-in-string " \" " " " version-string))))
322
+
323
+ (defun lsp-java--java-9-plus-p ()
324
+ " Check if java version is greater than or equal to 9."
325
+ (let ((java-version (lsp-java--get-java-version)))
326
+ (>= java-version 9 )))
327
+
311
328
(defun lsp-java--ls-command ()
312
329
" LS startup command."
313
330
(let ((server-jar (lsp-java--locate-server-jar))
314
331
(server-config (lsp-java--locate-server-config))
315
- (root-dir (lsp-java--get-root)))
332
+ (root-dir (lsp-java--get-root))
333
+ (java-9-args (if (lsp-java--java-9-plus-p)
334
+ lsp-java-9-args
335
+ '())))
316
336
(lsp-java--ensure-dir lsp-java-workspace-dir)
317
337
`(, lsp-java-java-path
318
338
" -Declipse.application=org.eclipse.jdt.ls.core.id1"
@@ -326,7 +346,8 @@ FULL specify whether full or incremental build will be performed."
326
346
" -configuration"
327
347
, server-config
328
348
" -data"
329
- , lsp-java-workspace-dir )))
349
+ , lsp-java-workspace-dir
350
+ ,@java-9-args )))
330
351
331
352
(defun lsp-java--get-root ()
332
353
" Retrieves the root directory of the java project root if available.
0 commit comments