From a2cb245d19f953140b1fdbb08e06547baf8fa3ee Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 21 Dec 2020 10:26:45 -0500 Subject: [PATCH] Display if server is a native binary in init message Adds a 'Native Image' entry to the initialization information. If LemMinX is running as a `native-image` binary, it is set to true. Closes #949 Signed-off-by: David Thompson --- .../java/org/eclipse/lemminx/utils/ServerInfo.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/utils/ServerInfo.java b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/utils/ServerInfo.java index 055ba7532..50f616cd0 100644 --- a/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/utils/ServerInfo.java +++ b/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/utils/ServerInfo.java @@ -21,6 +21,9 @@ public class ServerInfo { static final String MASTER = "master"; + // https://github.com/oracle/graal/blob/master/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java#L97 + private static final boolean IS_NATIVE_IMAGE = "Substrate VM".equals(System.getProperty("java.vm.name")); + private ResourceBundle rb = ResourceBundle.getBundle("git"); public ServerInfo() { @@ -80,14 +83,19 @@ public String toString() { * - Java : (path to java.home]) * - Git : ([Branch] short commit id - commit message) * - * + * * @return the formatted server details */ public String details() { StringBuilder details = new StringBuilder(); details.append("LemMinX Server info:"); append(details, "Version", getVersion()); - append(details, "Java", getJava()); + if (IS_NATIVE_IMAGE) { + append(details, "Native Image", null); + } else { + append(details, "Java", getJava()); + } + append(details, "VM Version", System.getProperty("java.vm.version")); append(details, "Git", null); String branch = getBranch(); if (!MASTER.equals(branch)) { @@ -111,4 +119,4 @@ private void append(StringBuilder sb, String key, String value){ .append(value); } } -} \ No newline at end of file +}