I am trying to implement the solution stated in this stackoverflow post.
As the solution suggests, I created a independent native library. This how I have implemented that library thus far.
#include "zoom_Main_VideoPlayer.h"
#include <dlfcn.h>
void *handle;
typedef int (*func)(int); // define function prototype
func myFunctionName; // some name for the function
JNIEXPORT void JNICALL Java_zoom_render_RenderView_naClose(JNIEnv *pEnv, jobject pObj) {
handle = dlopen("path to nativelibrary1.so", RTLD_LAZY);
myFunctionName = (func)dlsym(handle, "Close");
myFunctionName(1); // passing parameters if needed in the call
dlclose(handle);
return;
}
According to the solution, build another independent native library (utility library) to load and unload the other libraries. Thus, I am trying to load and unload nativelibrary1 in this independent library. For example, the native method in this other native library is such
// native method in nativelibrary1
JNIEXPORT void JNICALL Java_zoom_render_RenderView_naClose(JNIEnv *pEnv, jobject pObj) {
if (!is) {
do_exit(is);
}
else {
do_exit(NULL);
}
LOGI(0, "Clean-up done");
}
I am not sure how I am supposed to modify nativelibrary1 since they aren't native methods called directly in the java code anymore (the nativelibrary1 lib is not loaded directly in the static block of the java code).
Also am I supposed to change typedef int (*func)(int); // define function prototype
to fit the type of the method in nativelibrary1?