Using java invocation API from K/N

Hello. I try to call java code from native application using java invocation api. Also I want load libjvm using dlopen syscall.

headers = jni.h
libraryPaths = /usr/lib/jvm/java-1.11.0-openjdk-amd64/lib/server

compilerOpts.linux = -I/usr/lib/jvm/java-1.11.0-openjdk-amd64/include -I/usr/lib/jvm/java-1.11.0-openjdk-amd64/include/linux
package sample

import interop.*
import platform.posix.*
import kotlinx.cinterop.*

typealias createVm = (CValuesRef<CPointerVar<JavaVMVar>>?, CValuesRef<COpaquePointerVar>?, CValuesRef<*>?) -> jint

fun main() {
    val dl = dlopen("/usr/lib/jvm/java-11-openjdk-amd64/lib/server/", RTLD_LAZY)
    if (dl != null) {
        val createVm = dlsym(dl, "JNI_CreateJavaVM")
        if (createVm != null) {
            val createVmR: CPointer<CFunction<createVm>> = createVm.reinterpret()

I’ve figured out how to properly open library and get symbol from it. But I couldn’t figure out how to create corresponding structs for passing as createVmR arguments. Help please.

Here’s my generated interop file: (7.0 KB)