Accepted
charm.clj requires native terminal access for raw mode input, terminal size detection, and cursor control. JLine provides this functionality through multiple terminal providers:
jline-terminal-jni) - Uses Java Native Interface with bundled native librariesjline-terminal-ffm) - Uses Foreign Function & Memory API (JDK 21+)jline-terminal-jna) - Uses Java Native Accessjline-terminal) - Falls back to executing system commandsThe primary deployment target is GraalVM native-image and Babashka (which uses SCI interpreter on native-image).
Use the FFM provider (jline-terminal-ffm). Offer JNI as an alternative via parameter if people are complaining.
.so/.dylib/.dll files bundled in the JARFfmTerminalProvider directly, avoiding reflectionreachability-metadata.json with downcall descriptors-H:+ForeignAPISupport flagFFM downcalls must be pre-registered for native-image compilation. Required configuration in reachability-metadata.json:
{
"foreign": {
"downcalls": [
{
"parameterTypes": ["int", "long", "void*"],
"returnType": "int",
"options": {"firstVariadicArg": 2}
},
{
"parameterTypes": ["int"],
"returnType": "int"
},
{
"parameterTypes": ["int", "int", "void*"],
"returnType": "int"
},
{
"parameterTypes": ["int", "void*"],
"returnType": "int"
},
{
"parameterTypes": ["int", "void*", "long"],
"returnType": "int"
},
{
"parameterTypes": ["void*", "void*", "void*", "void*", "void*"],
"returnType": "int"
}
]
}
}
These correspond to the POSIX functions used by JLine's CLibrary:
ioctl(fd, request, ...) - terminal control (variadic)isatty(fd) - TTY detectiontcsetattr(fd, actions, termios*) - set terminal attributestcgetattr(fd, termios*) - get terminal attributesttyname_r(fd, buf*, size) - get TTY nameopenpty(master*, slave*, name*, termios*, winsize*) - open pseudo-terminal--enable-native-access=ALL-UNNAMED
-H:+ForeignAPISupport
-H:+UnlockExperimentalVMOptions (for GraalVM warnings)
The decision can be revisited if:
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |