Interop with non-Java libraries (FFI?)

In the Interop section of the documentation it talks about calling out to Java libraries (and vice versa), but it’s not clear how interop with other libraries (e.g. C libraries) should be done. JRuby, for example, has an FFI library, thus removing the need to use JNA directly. Will Kotlin provide a similar library?

The JRuby FFI exists to map the Ruby API to JNA, to keep compatibility with existing code. Kotlin doesn’t have a native FFI and so why would you add one just to map it to JNA/JNI/Panama later? You could as well use these things directly.

Kotlin supports JNI through the “external” modifier.

Here’s an example (need to replace “native” with “external”):