Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27652/src/java/org/lwjgl
Modified Files:
Sys.java
Log Message:
Implemented version check to check for incompatible native libraries
Index: Sys.java
===================================================================
RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/Sys.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- Sys.java 27 Mar 2004 13:48:57 -0000 1.43
+++ Sys.java 27 Mar 2004 14:09:53 -0000 1.44
@@ -47,6 +47,8 @@
* @version $Revision$
*/
public final class Sys {
+ public static final String VERSION = "0.9pre";
+
/** Low process priority. @see #setProcessPriority() */
public static final int LOW_PRIORITY = -1;
@@ -78,9 +80,9 @@
/** The native library name */
private static String LIBRARY_NAME = "lwjgl";
-
- /** The platform being executed on */
- private static String PLATFORM;
+
+ /** The platform being executed on */
+ private static String PLATFORM;
/**
* Debug flag.
@@ -91,12 +93,6 @@
static {
initialize();
-
- // check platform name, and default to awt
- PLATFORM = System.getProperty("org.lwjgl.Sys.platform");
- if(PLATFORM == null) {
- PLATFORM = "org.lwjgl.SwingAdapter";
- }
}
/**
@@ -130,9 +126,19 @@
return;
initialized = true;
System.loadLibrary(LIBRARY_NAME);
+ String native_version = getNativeLibraryVersion();
+ if (!native_version.equals(VERSION))
+ throw new IllegalStateException("Version mismatch: jar version is '" + VERSION +
+ "', native libary version is '" + native_version + "'");
setDebug(DEBUG);
setTime(0);
+ // check platform name, and default to awt
+ PLATFORM = System.getProperty("org.lwjgl.Sys.platform");
+ if(PLATFORM == null) {
+ PLATFORM = "org.lwjgl.SwingAdapter";
+ }
+
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
Display.resetDisplayMode();
@@ -148,7 +154,12 @@
}
/**
- * Set the debug level of the native library
+ * Return the version of the native library
+ */
+ private static native String getNativeLibraryVersion();
+
+ /**
+ * Set the debug level of the native library
*/
private static native void setDebug(boolean debug);
|