Skip to content

don't rely on JNI_GetCreatedJavaVMs #199

@user16332

Description

@user16332

For calls from Haskell into the JVM jni relies on a cached pointer to JNI's JavaVM struct. This pointer is currently obtained via the jvm function that calls JNI_GetCreatedJavaVMs: https://github.com/tweag/inline-java/blob/master/jni/src/common/Foreign/JNI/Unsafe/Internal.hs#L363 This call isn't available on Android.

One way to obtain this pointer is through the JNIEnv struct that is being passed by JNI on calls from Java (it has a member function GetJavaVM), and cache it in a global variable. This commit provides a Haskell jniInit function that users of the package have to call before making any calls back into Java. user16332@affeae4#diff-513af56a87e02a1e7a882ec00c88255da344d42b129da7da6308b34ac37408b9R361

Another solution would be to implement JNI_OnLoad which provides the pointer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions