ThreadContext context = runtime.getCurrentContext();
// Ensure the native code is initialized before we load the library
Native n = Native.getInstance(runtime);
Library lib = Library.openLibrary(name, Library.LAZY | Library.GLOBAL);
if (lib == null) {
throw new UnsatisfiedLinkError(Library.getLastError());
}
String fileName = new File(name).getName();
String initName = fileName;
int dotPos;
if ((dotPos = fileName.lastIndexOf('.')) != -1) {
// Remove the extension, if needed
initName = fileName.substring(0, dotPos);
}
long init = lib.getSymbolAddress("Init_" + initName);
if (init == 0) {
throw new UnsatisfiedLinkError("Could not locate Init_" + initName + " module entry point");
}