openLibrary(String pathname)1 public long openLibrary(String pathname) {
2   // Note we use RTLD_GLOBAL visibility to allow this functionality to
3   // be used to pre-resolve dependent libraries of JNI code without
4   // requiring that all references to symbols in those libraries be
5   // looked up dynamically via the ProcAddressTable mechanism; in
6   // other words, one can actually link against the library instead of
7   // having to dlsym all entry points. System.loadLibrary() uses
8   // RTLD_LOCAL visibility so can't be used for this purpose.
9   return dlopen(pathname, RTLD_GLOBAL);
10 }
11 
lookupSymbol(long libraryHandle, String symbolName)12 public long lookupSymbol(long libraryHandle, String symbolName) {
13   return dlsym(libraryHandle, symbolName);
14 }
15 
closeLibrary(long libraryHandle)16 public void closeLibrary(long libraryHandle) {
17   dlclose(libraryHandle);
18 }
19