Moved Sys.JNI_VERSION to SysImplementation.getRequiredJNIVersion() to enable platform specific native library versions.

This commit is contained in:
Elias Naur 2008-04-30 14:34:54 +00:00
parent e584a5e0a0
commit 100dfa86a6
5 changed files with 25 additions and 10 deletions

View file

@ -38,11 +38,15 @@ package org.lwjgl;
* @version $Revision$
* $Id$
*/
class LinuxSysImplementation extends J2SESysImplementation {
final class LinuxSysImplementation extends J2SESysImplementation {
static {
java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded
}
public int getRequiredJNIVersion() {
return 16;
}
public boolean openURL(final String url) {
// Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it
// right anyway.

View file

@ -44,12 +44,16 @@ import com.apple.eio.FileManager;
* @version $Revision$
* $Id$
*/
class MacOSXSysImplementation extends J2SESysImplementation {
final class MacOSXSysImplementation extends J2SESysImplementation {
static {
// Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3
Toolkit.getDefaultToolkit();
}
public int getRequiredJNIVersion() {
return 16;
}
public boolean openURL(String url) {
try {
FileManager.openURL(url);

View file

@ -56,9 +56,6 @@ public final class Sys {
/** Current version of library */
private static final String VERSION = "2.0b1";
/** Current version of the JNI library */
static final int JNI_VERSION = 16;
/** The implementation instance to delegate platform specific behavior to */
private final static SysImplementation implementation;
@ -101,8 +98,9 @@ public final class Sys {
loadLibrary(JNI_LIBRARY_NAME);
int native_jni_version = implementation.getJNIVersion();
if (native_jni_version != JNI_VERSION)
throw new LinkageError("Version mismatch: jar version is '" + JNI_VERSION +
int required_version = implementation.getRequiredJNIVersion();
if (native_jni_version != required_version)
throw new LinkageError("Version mismatch: jar version is '" + required_version +
"', native libary version is '" + native_jni_version + "'");
implementation.setDebug(LWJGLUtil.DEBUG);
}
@ -112,9 +110,9 @@ public final class Sys {
case LWJGLUtil.PLATFORM_LINUX:
return new LinuxSysImplementation();
case LWJGLUtil.PLATFORM_WINDOWS:
return new org.lwjgl.WindowsSysImplementation();
return new WindowsSysImplementation();
case LWJGLUtil.PLATFORM_MACOSX:
return new org.lwjgl.MacOSXSysImplementation();
return new MacOSXSysImplementation();
default:
throw new IllegalStateException("Unsupported platform");
}

View file

@ -41,6 +41,11 @@ package org.lwjgl;
* $Id$
*/
interface SysImplementation {
/**
* Return the required version of the native library
*/
int getRequiredJNIVersion();
/**
* Return the version of the native library
*/

View file

@ -38,11 +38,15 @@ package org.lwjgl;
* @version $Revision$
* $Id$
*/
class WindowsSysImplementation extends DefaultSysImplementation {
final class WindowsSysImplementation extends DefaultSysImplementation {
static {
Sys.initialize();
}
public int getRequiredJNIVersion() {
return 16;
}
public long getTimerResolution() {
return 1000;
}