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:
parent
676728bfd3
commit
3b03560ee7
|
@ -39,7 +39,10 @@ package org.lwjgl;
|
||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
abstract class DefaultSysImplementation implements SysImplementation {
|
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 native void setDebug(boolean debug);
|
||||||
|
|
||||||
public long getTimerResolution() {
|
public long getTimerResolution() {
|
||||||
|
|
|
@ -56,6 +56,9 @@ public final class Sys {
|
||||||
/** Current version of library */
|
/** Current version of library */
|
||||||
private static final String VERSION = "1.0beta2";
|
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 */
|
/** The implementation instance to delegate platform specific behavior to */
|
||||||
private final static SysImplementation implementation;
|
private final static SysImplementation implementation;
|
||||||
|
|
||||||
|
@ -97,10 +100,10 @@ public final class Sys {
|
||||||
implementation = createImplementation();
|
implementation = createImplementation();
|
||||||
loadLibrary(JNI_LIBRARY_NAME);
|
loadLibrary(JNI_LIBRARY_NAME);
|
||||||
|
|
||||||
String native_version = implementation.getNativeLibraryVersion();
|
int native_jni_version = implementation.getJNIVersion();
|
||||||
if (!native_version.equals(getVersion()))
|
if (native_jni_version != JNI_VERSION)
|
||||||
throw new LinkageError("Version mismatch: jar version is '" + getVersion() +
|
throw new LinkageError("Version mismatch: jar version is '" + JNI_VERSION +
|
||||||
"', native libary version is '" + native_version + "'");
|
"', native libary version is '" + native_jni_version + "'");
|
||||||
implementation.setDebug(LWJGLUtil.DEBUG);
|
implementation.setDebug(LWJGLUtil.DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ interface SysImplementation {
|
||||||
/**
|
/**
|
||||||
* Return the version of the native library
|
* Return the version of the native library
|
||||||
*/
|
*/
|
||||||
String getNativeLibraryVersion();
|
int getJNIVersion();
|
||||||
|
|
||||||
void setDebug(boolean debug);
|
void setDebug(boolean debug);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#include "org_lwjgl_DefaultSysImplementation.h"
|
#include "org_lwjgl_DefaultSysImplementation.h"
|
||||||
|
|
||||||
static bool debug = false;
|
static bool debug = false;
|
||||||
static const char* VERSION = "1.0beta2";
|
|
||||||
static JavaVM *jvm;
|
static JavaVM *jvm;
|
||||||
|
|
||||||
void initAttribList(attrib_list_t *list) {
|
void initAttribList(attrib_list_t *list) {
|
||||||
|
@ -64,9 +63,9 @@ void putAttrib(attrib_list_t *list, int attrib) {
|
||||||
list->current_index++;
|
list->current_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL Java_org_lwjgl_DefaultSysImplementation_getNativeLibraryVersion
|
JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion
|
||||||
(JNIEnv *env, jobject ignored) {
|
(JNIEnv *env, jobject ignored) {
|
||||||
return NewStringNative(env, VERSION);
|
return org_lwjgl_DefaultSysImplementation_JNI_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_DefaultSysImplementation_setDebug
|
JNIEXPORT void JNICALL Java_org_lwjgl_DefaultSysImplementation_setDebug
|
||||||
|
|
Loading…
Reference in New Issue