parent
800ba0a969
commit
eba1a5c2cf
|
@ -31,8 +31,13 @@
|
||||||
*/
|
*/
|
||||||
package org.lwjgl.devil;
|
package org.lwjgl.devil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
import org.lwjgl.LWJGLUtil;
|
import org.lwjgl.LWJGLUtil;
|
||||||
|
import org.lwjgl.applet.LWJGLInstaller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -45,8 +50,44 @@ import org.lwjgl.LWJGLUtil;
|
||||||
*/
|
*/
|
||||||
class ILNative {
|
class ILNative {
|
||||||
|
|
||||||
|
/** The native JNI library name */
|
||||||
|
private static String JNI_LIBRARY_NAME = "lwjgl-devil";
|
||||||
|
|
||||||
|
/** Version of IL */
|
||||||
|
public static final String VERSION = "1.0beta2";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* utility loadlibrary to load the native library using elevated priviledges
|
||||||
|
* @param name Name of library to load, or full path if usingPath is true
|
||||||
|
* @param usingPath true if using the full path to the native
|
||||||
|
*/
|
||||||
|
private static void loadLibrary(final String name, final boolean usingPath) {
|
||||||
|
AccessController.doPrivileged(new PrivilegedAction() {
|
||||||
|
public Object run() {
|
||||||
|
if(usingPath) {
|
||||||
|
System.load(name);
|
||||||
|
} else {
|
||||||
|
System.loadLibrary(name);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("lwjgl-devil");
|
if (LWJGLInstaller.installed) {
|
||||||
|
loadLibrary(LWJGLInstaller.installDirectory + File.separator + System.mapLibraryName(JNI_LIBRARY_NAME), true);
|
||||||
|
} else {
|
||||||
|
loadLibrary(JNI_LIBRARY_NAME, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for mismatch
|
||||||
|
String nativeVersion = getNativeLibraryVersion();
|
||||||
|
if (!nativeVersion.equals(VERSION)) {
|
||||||
|
throw new LinkageError(
|
||||||
|
"Version mismatch: jar version is '" + VERSION +
|
||||||
|
"', native libary version is '" + nativeVersion + "'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IL
|
// IL
|
||||||
|
@ -55,6 +96,7 @@ class ILNative {
|
||||||
static native void resetNativeStubsIL(Class clazz);
|
static native void resetNativeStubsIL(Class clazz);
|
||||||
static native void nCreateIL(String[] ilPaths) throws LWJGLException;
|
static native void nCreateIL(String[] ilPaths) throws LWJGLException;
|
||||||
static native void nDestroyIL();
|
static native void nDestroyIL();
|
||||||
|
private static native String getNativeLibraryVersion();
|
||||||
|
|
||||||
static void createIL() throws LWJGLException {
|
static void createIL() throws LWJGLException {
|
||||||
String[] illPaths = LWJGLUtil.getLibraryPaths(new String[]{
|
String[] illPaths = LWJGLUtil.getLibraryPaths(new String[]{
|
||||||
|
|
Loading…
Reference in New Issue