From: <eli...@us...> - 2006-07-14 16:15:05
|
Revision: 2514 Author: elias_naur Date: 2006-07-14 09:14:52 -0700 (Fri, 14 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2514&view=rev Log Message: ----------- 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 ;) Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java trunk/LWJGL/src/native/common/common_tools.c Modified: trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java 2006-07-14 13:07:38 UTC (rev 2513) +++ trunk/LWJGL/src/java/org/lwjgl/DefaultSysImplementation.java 2006-07-14 16:14:52 UTC (rev 2514) @@ -39,7 +39,10 @@ * $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() { Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-14 13:07:38 UTC (rev 2513) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-14 16:14:52 UTC (rev 2514) @@ -56,6 +56,9 @@ /** 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 @@ 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); } Modified: trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java 2006-07-14 13:07:38 UTC (rev 2513) +++ trunk/LWJGL/src/java/org/lwjgl/SysImplementation.java 2006-07-14 16:14:52 UTC (rev 2514) @@ -44,7 +44,7 @@ /** * Return the version of the native library */ - String getNativeLibraryVersion(); + int getJNIVersion(); void setDebug(boolean debug); Modified: trunk/LWJGL/src/native/common/common_tools.c =================================================================== --- trunk/LWJGL/src/native/common/common_tools.c 2006-07-14 13:07:38 UTC (rev 2513) +++ trunk/LWJGL/src/native/common/common_tools.c 2006-07-14 16:14:52 UTC (rev 2514) @@ -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 @@ 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |