From: <ma...@us...> - 2006-07-02 21:57:04
|
Revision: 2411 Author: matzon Date: 2006-07-02 14:56:57 -0700 (Sun, 02 Jul 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2411&view=rev Log Message: ----------- preliminary applet support Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/Sys.java Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-02 21:55:09 UTC (rev 2410) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2006-07-02 21:56:57 UTC (rev 2411) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2004 LWJGL Project + * Copyright (c) 2002-2006 LWJGL Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,7 @@ */ package org.lwjgl; +import java.io.File; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; @@ -38,6 +39,7 @@ import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; +import org.lwjgl.applet.LWJGLInstaller; import org.lwjgl.input.Mouse; /** @@ -51,15 +53,24 @@ public final class Sys { /** Current version of library */ - private static final String VERSION = "1.0beta"; + private static final String VERSION = "1.0beta2"; /** The implementation instance to delegate platform specific behavior to */ private final static SysImplementation implementation; - private static void loadLibrary(final String name) { + /** + * utility loadlibrary to load the native library using elevated priviledges + * @param name Name of library to load, or full path if usingPath is true + * @param usingPath true if using the full path to the native + */ + private static void loadLibrary(final String name, final boolean usingPath) { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { - System.loadLibrary(name); + if(usingPath) { + System.load(name); + } else { + System.loadLibrary(name); + } return null; } }); @@ -71,15 +82,32 @@ UnsatisfiedLinkError last_load_error = null; for (int i = 0; i < library_names.length; i++) { try { - loadLibrary(library_names[i]); + loadLibrary(library_names[i], false); last_load_error = null; break; } catch (UnsatisfiedLinkError e) { last_load_error = e; } } - if (last_load_error != null) + + // failed normal loading - check installer + if (last_load_error != null && LWJGLInstaller.installed) { + for (int i = 0; i < library_names.length; i++) { + try { + loadLibrary(LWJGLInstaller.installDirectory + File.separator + System.mapLibraryName(library_names[i]), true); + last_load_error = null; + break; + } catch (UnsatisfiedLinkError e) { + last_load_error = e; + } + } + } + + // check for error + if (last_load_error != null) { throw last_load_error; + } + String native_version = implementation.getNativeLibraryVersion(); if (!native_version.equals(getVersion())) throw new LinkageError("Version mismatch: jar version is '" + getVersion() + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |