Skip to content

Commit 9ecdcde

Browse files
Update Jansi to 2.4.1 (#106)
* Bump Jansi to 2.4.1 * Add workaround for jansi 2.4.1 Windows ARM64 issue --------- Co-authored-by: Alex Archambault <alexandre.archambault@gmail.com>
1 parent 6b2b16e commit 9ecdcde

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ lazy val jni = project
3030
shared,
3131
name := "windows-ansi",
3232
libraryDependencies ++= Seq(
33-
"org.fusesource.jansi" % "jansi" % "1.18"
33+
"org.fusesource.jansi" % "jansi" % "2.4.1",
3434
)
3535
)
3636

jni/src/main/java/io/github/alexarchambault/windowsansi/WindowsAnsi.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
package io.github.alexarchambault.windowsansi;
22

33
import org.fusesource.jansi.internal.Kernel32;
4-
import org.fusesource.jansi.internal.WindowsSupport;
54

65
import java.io.IOException;
6+
import java.net.URL;
7+
import java.util.Locale;
78
import java.util.Objects;
89

910
public final class WindowsAnsi {
1011

1112
static {
13+
// Workaround while we can't benefit from https://github.com/fusesource/jansi/pull/292
14+
String arch = System.getProperty("os.arch", "").toLowerCase(Locale.ROOT);
15+
if (arch.equals("arm64") || arch.equals("aarch64")) {
16+
ClassLoader cl = Thread.currentThread().getContextClassLoader();
17+
URL dllUrl = cl.getResource("org/fusesource/jansi/internal/native/Windows/arm64/jansi.dll");
18+
URL soUrl = cl.getResource("org/fusesource/jansi/internal/native/Windows/arm64/libjansi.so");
19+
if (dllUrl == null && soUrl != null) {
20+
System.setProperty("library.jansi.name", "libjansi.so");
21+
}
22+
}
23+
1224
// Make https://github.com/fusesource/hawtjni/blob/c14fec00b9976ff6b84e62e483d678594a7d3832/hawtjni-runtime/src/main/java/org/fusesource/hawtjni/runtime/Library.java#L167 happy
1325
if (System.getProperty("com.ibm.vm.bitmode") == null)
1426
System.setProperty("com.ibm.vm.bitmode", "64");
@@ -31,7 +43,7 @@ public static boolean setup() throws IOException {
3143
long console = Kernel32.GetStdHandle(Kernel32.STD_OUTPUT_HANDLE);
3244
int[] mode = new int[1];
3345
if (Kernel32.GetConsoleMode(console, mode) == 0)
34-
throw new IOException("Failed to get console mode: " + WindowsSupport.getLastErrorMessage());
46+
throw new IOException("Failed to get console mode: " + Kernel32.getLastErrorMessage());
3547
return Kernel32.SetConsoleMode(console, mode[0] | ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0;
3648
}
3749

0 commit comments

Comments
 (0)