Detect JDK version and modify java args accordingly

This commit is contained in:
Carlo Sciolla 2019-09-04 23:32:28 +02:00
parent 5889166b6c
commit 2fd42ff701
No known key found for this signature in database
GPG Key ID: BA5D71E6F3C580C1
1 changed files with 19 additions and 7 deletions

View File

@ -241,6 +241,15 @@
(message "Aborted.")) (message "Aborted."))
(message "Aborted."))) (message "Aborted.")))
(defun plantuml-jar-java-version ()
"Inspects the Java runtime version of the configured Java command in `plantuml-java-command'."
(save-excursion
(save-match-data
(with-temp-buffer
(call-process plantuml-java-command nil t nil "-XshowSettings:properties" "-version")
(re-search-backward "java.version = \\(1.\\)?\\([[:digit:]]+\\)")
(string-to-number (match-string 2))))))
(defun plantuml-jar-get-language (buf) (defun plantuml-jar-get-language (buf)
"Retrieve the language specification from the PlantUML JAR file and paste it into BUF." "Retrieve the language specification from the PlantUML JAR file and paste it into BUF."
(unless (or (eq system-type 'cygwin) (file-exists-p plantuml-jar-path)) (unless (or (eq system-type 'cygwin) (file-exists-p plantuml-jar-path))
@ -358,13 +367,16 @@ Note that output type `txt' is promoted to `utxt' for better rendering."
(defun plantuml-jar-start-process (buf) (defun plantuml-jar-start-process (buf)
"Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)." "Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)."
(apply #'start-process (let ((java-args (if (<= 8 (plantuml-jar-java-version))
"PLANTUML" buf plantuml-java-command (remove "--illegal-access=deny" plantuml-java-args)
`(,@plantuml-java-args plantuml-java-args)))
,(expand-file-name plantuml-jar-path) (apply #'start-process
,(plantuml-jar-output-type-opt plantuml-output-type) "PLANTUML" buf plantuml-java-command
,@plantuml-jar-args `(,@java-args
"-p"))) ,(expand-file-name plantuml-jar-path)
,(plantuml-jar-output-type-opt plantuml-output-type)
,@java-args
"-p"))))
(defun plantuml-executable-start-process (buf) (defun plantuml-executable-start-process (buf)
"Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)." "Run PlantUML as an Emacs process and puts the output into the given buffer (as BUF)."