Split the external LWJGL version from the internal version of the native JNI library. The internal JNI version is now an integer. This has multiple advantages over the old way:

1. The JNI_VERSION field is now included automatically in the generated JNI headers, relieving us of the burden of updating the version number in both java and native code.
2. We can update the JNI version with every non-compatible change of the JNI library API, not just once per release, giving us extra safety when users download and build LWJGL from SVN.
3. We can now avoid rebuilding natives if a particular release only
contains java changes. Currently, This is mostly a problem when Brian bumps the
external version prior a release and I forget to re-build the natives ;)
This commit is contained in:
Elias Naur 2006-07-14 16:14:52 +00:00
parent 676728bfd3
commit 3b03560ee7
4 changed files with 14 additions and 9 deletions

View File

@ -39,7 +39,10 @@ package org.lwjgl;
* $Id$
*/
abstract class DefaultSysImplementation implements SysImplementation {
public native String getNativeLibraryVersion();
/** Included to let native have easy access to Sys.JNI_VERSION */
private final static int JNI_VERSION = Sys.JNI_VERSION;
public native int getJNIVersion();
public native void setDebug(boolean debug);
public long getTimerResolution() {

View File

@ -56,6 +56,9 @@ public final class Sys {
/** Current version of library */
private static final String VERSION = "1.0beta2";
/** Current version of the JNI library */
static final int JNI_VERSION = 1;
/** The implementation instance to delegate platform specific behavior to */
private final static SysImplementation implementation;
@ -97,10 +100,10 @@ public final class Sys {
implementation = createImplementation();
loadLibrary(JNI_LIBRARY_NAME);
String native_version = implementation.getNativeLibraryVersion();
if (!native_version.equals(getVersion()))
throw new LinkageError("Version mismatch: jar version is '" + getVersion() +
"', native libary version is '" + native_version + "'");
int native_jni_version = implementation.getJNIVersion();
if (native_jni_version != JNI_VERSION)
throw new LinkageError("Version mismatch: jar version is '" + JNI_VERSION +
"', native libary version is '" + native_jni_version + "'");
implementation.setDebug(LWJGLUtil.DEBUG);
}

View File

@ -44,7 +44,7 @@ interface SysImplementation {
/**
* Return the version of the native library
*/
String getNativeLibraryVersion();
int getJNIVersion();
void setDebug(boolean debug);

View File

@ -48,7 +48,6 @@
#include "org_lwjgl_DefaultSysImplementation.h"
static bool debug = false;
static const char* VERSION = "1.0beta2";
static JavaVM *jvm;
void initAttribList(attrib_list_t *list) {
@ -64,9 +63,9 @@ void putAttrib(attrib_list_t *list, int attrib) {
list->current_index++;
}
JNIEXPORT jstring JNICALL Java_org_lwjgl_DefaultSysImplementation_getNativeLibraryVersion
JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion
(JNIEnv *env, jobject ignored) {
return NewStringNative(env, VERSION);
return org_lwjgl_DefaultSysImplementation_JNI_VERSION;
}
JNIEXPORT void JNICALL Java_org_lwjgl_DefaultSysImplementation_setDebug