Skip to main content
added 408 characters in body
Source Link

if you want call it directly from java code, it won't work because jvm does not recognize it. But you can write a proxy so file which would call the fun function.

example

 void *handler= dlopen("libxxx.so", RTLD_LAZY);//open the so
 void *(*fun)(); //the definition of the fun pointer you want to call
 fun = (void *(*)())dlsym(handler,"fun"); // get the dynsym
 fun(); //call it

note: need check : handler != NULL && fun != NULL

you can get the dynamic symbol use readelf tool in linux

if you want call it directly from java code, it won't work because jvm does not recognize it. But you can write a proxy so file which would call the fun function.

if you want call it directly from java code, it won't work because jvm does not recognize it. But you can write a proxy so file which would call the fun function.

example

 void *handler= dlopen("libxxx.so", RTLD_LAZY);//open the so
 void *(*fun)(); //the definition of the fun pointer you want to call
 fun = (void *(*)())dlsym(handler,"fun"); // get the dynsym
 fun(); //call it

note: need check : handler != NULL && fun != NULL

you can get the dynamic symbol use readelf tool in linux

typos
Source Link
Igor Skochinsky
  • 36.9k
  • 7
  • 65
  • 116

if you want call it directly from java code,it couldn't. it won't work because jvm dosedoes not recognize it. butBut you can write a proxy so file which would call the fun function in it.

if you want call it directly from java code,it couldn't. because jvm dose not recognize it. but you can write a proxy so file which call the fun function in it.

if you want call it directly from java code, it won't work because jvm does not recognize it. But you can write a proxy so file which would call the fun function.

Source Link

if you want call it directly from java code,it couldn't. because jvm dose not recognize it. but you can write a proxy so file which call the fun function in it.