File: dynlink-unix-CustomJavaCode.java

package info (click to toggle)
gluegen2 2.0-rc5-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,520 kB
  • sloc: java: 19,567; xml: 2,056; ansic: 1,434; sh: 588; makefile: 67
file content (18 lines) | stat: -rwxr-xr-x 756 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public long openLibrary(String pathname) {
  // Note we use RTLD_GLOBAL visibility to allow this functionality to
  // be used to pre-resolve dependent libraries of JNI code without
  // requiring that all references to symbols in those libraries be
  // looked up dynamically via the ProcAddressTable mechanism; in
  // other words, one can actually link against the library instead of
  // having to dlsym all entry points. System.loadLibrary() uses
  // RTLD_LOCAL visibility so can't be used for this purpose.
  return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL);
}

public long lookupSymbol(long libraryHandle, String symbolName) {
  return dlsym(libraryHandle, symbolName);
}

public void closeLibrary(long libraryHandle) {
  dlclose(libraryHandle);
}