How do I access JavaVM from androidNativeArm32 without NativeActivity and from a library?

I originally created this post here: How do I access JavaVM from androidNativeArm32 without NativeActivity and from a library? · Issue #2331 · JetBrains/kotlin-native · GitHub

but I figure this place might be better suited for asking for help rather than reporting an issue.

Onto the question:

Following the example demonstrated in: https://github.com/JetBrains/kotlin-native/blob/master/samples/androidNativeActivity

I got the main idea on how to call Android API’s from native code, however. I can not rely on NativeActivity being used and need some sort of way to gain access to JavaVM

My current idea is to setup the library with

@CName("JNI_OnLoad")
fun JNI_OnLoad(vm: kotlinx.cinterop.CValuesRef<platform.android.JavaVMVar>?, reserved: kotlinx.cinterop.CValuesRef<*>?): platform.android.jint {
    __android_log_write(ANDROID_LOG_INFO.convert(), "KonanActivity", "JNI BOOTED UP!")
    return JNI_VERSION_1_2
}

@CName("JNI_OnUnload")
fun JNI_OnUnload(vm: kotlinx.cinterop.CValuesRef<platform.android.JavaVMVar >?, reserved: kotlinx.cinterop.CValuesRef<*>?): kotlin.Unit {
    __android_log_write(ANDROID_LOG_INFO.convert(), "KonanActivity", "JNI SHUT DOWN!")
}

In order to gain access to the JavaVM and then proceed to setting it up like in the repository linked above.

However this will cause issues to the exported *.so file because the types won’t be handled properly. What would be the easiest way to gain access to the JavaVM the library is attached to?