Access to OS specific constants
Guillaume Nodet
gnodet at apache.org
Fri Jun 3 12:47:47 UTC 2022
I'm experimenting JEP 424 to support Jansi (
https://github.com/fusesource/jansi), JLine (https://github.com/jline/jline3)
and mvnd (https://github.com/apache/maven-mvnd).
I've been able to replace a few native calls with the experimental API
[1]. However, there's one thing I'd be missing in order to completely get
rid of the native code : the java code needs to call the ioctl function
[2], but that one takes an integer which value is defined in C headers. In
my case, this is the TIOCGWINSZ constant, which is defined in my library
class [3] and initialized in the native code [4]. When the libraries are
using JNA, I need to define specific constants for each system, see [5],
[6], [7]. But this kinda defeats the purpose of portability.
Any idea how to work around this problem ?
Cheers,
Guillaume Nodet
[1] https://github.com/fusesource/jansi/tree/jep-424
[2]
https://github.com/fusesource/jansi/blob/jep-424/src/main/java/org/fusesource/jansi/AnsiConsoleHelper.java#L82
[3]
https://github.com/fusesource/jansi/blob/jep-424/src/main/java/org/fusesource/jansi/internal/CLibrary.java#L63
[4]
https://github.com/fusesource/jansi/blob/jep-424/src/main/native/jansi.c#L58
[5]
https://github.com/jline/jline3/blob/master/terminal-jna/src/main/java/org/jline/terminal/impl/jna/freebsd/CLibrary.java#L250
[6]
https://github.com/jline/jline3/blob/master/terminal-jna/src/main/java/org/jline/terminal/impl/jna/linux/CLibrary.java#L267
[7]
https://github.com/jline/jline3/blob/master/terminal-jna/src/main/java/org/jline/terminal/impl/jna/solaris/CLibrary.java#L267
--
------------------------
Guillaume Nodet
More information about the panama-dev
mailing list