picocli.jansi.graalvm.Workaround Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of picocli-jansi-graalvm Show documentation
Show all versions of picocli-jansi-graalvm Show documentation
${rootProject.name} - Create native Windows executable command line applications with colors in Java.
package picocli.jansi.graalvm;
/**
* Enables the use of Jansi native library code in GraalVM native image applications.
*
* This class provides a workaround for a problem in Jansi's
* org.fusesource.hawtjni.runtime.Library
* that prevents the native libraries embedded in the Jansi JAR in
* /META-INF/native/*
from being loaded
* when running in a GraalVM native image.
*
*
* Usage: call {@code Workaround.enableLibraryLoad()} before calling any Jansi code.
* For example:
*
*
* import org.fusesource.jansi.internal.WindowsSupport;
* import picocli.jansi.substratevm.Workaround;
*
* public class OtherApp {
*
* static {
* Workaround.enableLibraryLoad();
* }
*
* public static void main(String[] args) {
* int width = WindowsSupport.getWindowsTerminalWidth();
* doCoolStuff(width);
* }
* // ...
* }
*
*/
public class Workaround {
private Workaround() {}
// workaround for https://github.com/fusesource/jansi/issues/162
public static void enableLibraryLoad() {
String arch = System.getProperty("os.arch");
String vm = System.getProperty("java.vm.name");
if (arch.endsWith("64") && "Substrate VM".equals(vm)) {
System.setProperty("sun.arch.data.model", "64");
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy