Skip to content

Unable to test custom JNI Lib when loading native library #481

Answered by lacasseio
jilliam asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry for the delay in the response. So the issue is actually with how exported methods are named. The error message is correct, I simply misinterpreted it. The prebuilt binaries in the example are built for com.example.greeter.Greeter#sayHello. If we list the symbols on the prebuilt binaries, we can see the following (for macOS):

...
0000000000000bb0 T _Java_com_example_greeter_Greeter_sayHello
...

The encoding here is how JNI expects the native methods to be exported. The generated JNI header from javac usually takes care of the for you. For example, the JNI signature for the rename you performed is: JNIEXPORT jstring JNICALL Java_com_example_loader_Loader_sayHello (JNIEnv *, jobject, …

Replies: 7 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by lacasseio
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jilliam
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #474 on November 27, 2021 14:50.