diff --git a/build.xml b/build.xml index 089d33af..5c82303d 100644 --- a/build.xml +++ b/build.xml @@ -177,6 +177,7 @@ + @@ -202,6 +203,7 @@ + diff --git a/src/java/org/lwjgl/DefaultSysImplementation.java b/src/java/org/lwjgl/DefaultSysImplementation.java index d2de8e56..265b0e13 100644 --- a/src/java/org/lwjgl/DefaultSysImplementation.java +++ b/src/java/org/lwjgl/DefaultSysImplementation.java @@ -39,9 +39,6 @@ package org.lwjgl; * $Id$ */ abstract class DefaultSysImplementation implements SysImplementation { - /** 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); diff --git a/src/java/org/lwjgl/LinuxSysImplementation.java b/src/java/org/lwjgl/LinuxSysImplementation.java index 543225c2..6ba86e71 100644 --- a/src/java/org/lwjgl/LinuxSysImplementation.java +++ b/src/java/org/lwjgl/LinuxSysImplementation.java @@ -39,12 +39,14 @@ package org.lwjgl; * $Id$ */ final class LinuxSysImplementation extends J2SESysImplementation { + private final static int JNI_VERSION = 16; + static { java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded } public int getRequiredJNIVersion() { - return 16; + return JNI_VERSION; } public boolean openURL(final String url) { diff --git a/src/java/org/lwjgl/MacOSXSysImplementation.java b/src/java/org/lwjgl/MacOSXSysImplementation.java index 5dd85bd0..078baa3b 100644 --- a/src/java/org/lwjgl/MacOSXSysImplementation.java +++ b/src/java/org/lwjgl/MacOSXSysImplementation.java @@ -45,13 +45,15 @@ import com.apple.eio.FileManager; * $Id$ */ final class MacOSXSysImplementation extends J2SESysImplementation { + private final static int JNI_VERSION = 16; + static { // Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3 Toolkit.getDefaultToolkit(); } public int getRequiredJNIVersion() { - return 16; + return JNI_VERSION; } public boolean openURL(String url) { diff --git a/src/java/org/lwjgl/WindowsSysImplementation.java b/src/java/org/lwjgl/WindowsSysImplementation.java index 691ec1f3..64ab673c 100644 --- a/src/java/org/lwjgl/WindowsSysImplementation.java +++ b/src/java/org/lwjgl/WindowsSysImplementation.java @@ -39,12 +39,14 @@ package org.lwjgl; * $Id$ */ final class WindowsSysImplementation extends DefaultSysImplementation { + private final static int JNI_VERSION = 16; + static { Sys.initialize(); } public int getRequiredJNIVersion() { - return 16; + return JNI_VERSION; } public long getTimerResolution() { diff --git a/src/native/common/common_tools.c b/src/native/common/common_tools.c index 25f2be21..c5c9acd4 100644 --- a/src/native/common/common_tools.c +++ b/src/native/common/common_tools.c @@ -58,11 +58,6 @@ void putAttrib(attrib_list_t *list, int attrib) { list->current_index++; } -JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion - (JNIEnv *env, jobject ignored) { - return org_lwjgl_DefaultSysImplementation_JNI_VERSION; -} - JNIEXPORT void JNICALL Java_org_lwjgl_DefaultSysImplementation_setDebug (JNIEnv *env, jobject ignored, jboolean enable) { debug = enable == JNI_TRUE ? true : false; diff --git a/src/native/linux/org_lwjgl_opengl_Display.c b/src/native/linux/org_lwjgl_opengl_Display.c index cb0838c9..483699ca 100644 --- a/src/native/linux/org_lwjgl_opengl_Display.c +++ b/src/native/linux/org_lwjgl_opengl_Display.c @@ -54,6 +54,7 @@ #include "context.h" #include "org_lwjgl_opengl_LinuxDisplay.h" #include "org_lwjgl_opengl_LinuxDisplayPeerInfo.h" +#include "org_lwjgl_LinuxSysImplementation.h" #define ERR_MSG_SIZE 1024 @@ -108,6 +109,11 @@ static jlong openDisplay(JNIEnv *env) { return (intptr_t)display_connection; } +JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion + (JNIEnv *env, jobject ignored) { + return org_lwjgl_LinuxSysImplementation_JNI_VERSION; +} + JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_LinuxDisplay_getErrorText(JNIEnv *env, jclass unused, jlong display_ptr, jlong error_code) { Display *disp = (Display *)(intptr_t)display_ptr; char err_msg_buffer[ERR_MSG_SIZE]; diff --git a/src/native/macosx/org_lwjgl_opengl_Display.m b/src/native/macosx/org_lwjgl_opengl_Display.m index 1241b654..96002d83 100644 --- a/src/native/macosx/org_lwjgl_opengl_Display.m +++ b/src/native/macosx/org_lwjgl_opengl_Display.m @@ -47,9 +47,15 @@ //#import "display.h" #import "common_tools.h" #import "org_lwjgl_opengl_MacOSXDisplay.h" +#import "org_lwjgl_MacOSXSysImplementation.h" #define WAIT_DELAY 100 +JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion + (JNIEnv *env, jobject ignored) { + return org_lwjgl_MacOSXSysImplementation_JNI_VERSION; +} + JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXDisplay_restoreGamma(JNIEnv *env, jobject this) { CGDisplayRestoreColorSyncSettings(); } diff --git a/src/native/windows/org_lwjgl_opengl_Display.c b/src/native/windows/org_lwjgl_opengl_Display.c index e0868f52..230c2f7e 100644 --- a/src/native/windows/org_lwjgl_opengl_Display.c +++ b/src/native/windows/org_lwjgl_opengl_Display.c @@ -47,6 +47,7 @@ #include "common_tools.h" #include "display.h" #include "org_lwjgl_opengl_WindowsDisplay.h" +#include "org_lwjgl_WindowsSysImplementation.h" #include "context.h" static HICON small_icon = NULL; @@ -178,6 +179,11 @@ JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_opengl_WindowsDisplay_getAvailable return getAvailableDisplayModes(env); } +JNIEXPORT jint JNICALL Java_org_lwjgl_DefaultSysImplementation_getJNIVersion + (JNIEnv *env, jobject ignored) { + return org_lwjgl_WindowsSysImplementation_JNI_VERSION; +} + static void destroyWindow(JNIEnv *env) { jclass display_class_global = (jclass)(LONG_PTR)GetWindowLongPtr(display_hwnd, GWLP_USERDATA); closeWindow(&display_hwnd, &display_hdc);