(lsp-java--get-java-version) buggy
Opened this issue · 0 comments
SreenivasVRao commented
Describe the bug
I see that this is parsing the shell output of java -version
and that seems to break:
$ java -version
Picked up JAVA_TOOL_OPTIONS: -Dlog4j2.formatMsgNoLookups=true
openjdk version "17.0.8.1" 2023-08-24
OpenJDK Runtime Environment Homebrew (build 17.0.8.1+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.8.1+0, mixed mode, sharing)
Output of (shell-command-to-string "java -version")
:
"Picked up JAVA_TOOL_OPTIONS: -Dlog4j2.formatMsgNoLookups=true
openjdk version \"17.0.8.1\" 2023-08-24
OpenJDK Runtime Environment Homebrew (build 17.0.8.1+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.8.1+0, mixed mode, sharing)
"
Can be fixed by tweaking the command as follows:
(defun lsp-java--get-java-version ()
"Retrieve the java version from shell command."
(let* ((java-version-output (shell-command-to-string (concat lsp-java-java-path " -version")))
(version-string (nth 0 (split-string (nth 1 (split-string java-version-output "version"))))))
(string-to-number (replace-regexp-in-string "\"" "" version-string))))