Skip to content

Suggestion to use two main files for JNI #62

@paulocoutinhox

Description

@paulocoutinhox

Hi,

I think that we can have two main files for JNI.

I remember where i use it before in a project.

Android projects that use libraries like SDL2 already have JNI_OnLoad. See:

https://github.com/libsdl-org/SDL/blob/98a966d1c20afc0abd27d8cd449810893104a908/src/core/android/SDL_android.c#L506-L522

And this function is called here on JVM:
https://android.googlesource.com/platform/dalvik/+/eclair-release/vm/Native.c#532

And the problem is duplicate the entrypoint for function JNI_OnLoad. This problem is described here:
https://engineering.fb.com/2018/01/23/android/android-native-library-merging/

A solution that i created to my projects is have two "main" files for Android. One is your original implementation today and other is initialize djinni after other libraries already initialize JNI. It let library developer choose what implementation use.

My files:
https://github.com/ezored/ezored/blob/version-3/files/modules/support-lib/djinni/jni/main/djinni_jni_main.hpp
and
https://github.com/ezored/ezored/blob/version-3/files/modules/support-lib/djinni/jni/main-ext/djinni_jni_main.hpp

Other references if need:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions