Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(lsp-java--get-java-version) buggy #457

Open
SreenivasVRao opened this issue Sep 25, 2023 · 0 comments
Open

(lsp-java--get-java-version) buggy #457

SreenivasVRao opened this issue Sep 25, 2023 · 0 comments

Comments

@SreenivasVRao
Copy link
Contributor

SreenivasVRao commented Sep 25, 2023

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))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant