LWJGL Forum

Archive => Resolved Bugs/RFE => Topic started by: arielsan on January 24, 2011, 20:50:34

Title: [FIXED] AppletLoader change natives parameters to accept a list of jars
Post by: arielsan on January 24, 2011, 20:50:34
It could be really helpful to treat the natives parameters like the jars parameters, a list of items separated by ','

An example:


<applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="640" height="480">
   ...
   <param name="al_windows" value="windows_natives.jar, my_custom_natives-win.jar">
   ...
</applet>


I want to propose a patch but first I wanna know if there are no problems with this request and/or if exists another solution already.
Title: Re: [RFE] AppletLoader change natives parameters to accept a list of jars
Post by: bobjob on January 24, 2011, 22:24:05
for custom natives files from a seperate Jar file/s, It should probably be implemented as another tag (optional). It should be done using the following method to add them to the library path (as its unlikely that the lwjgl library property would be needed).

public void addDir(String nativeLibraryPath) throws IOException {
try {
Field field = ClassLoader.class.getDeclaredField("usr_paths");
field.setAccessible(true);
String[] paths = (String[])field.get(null);
for (int i = 0; i < paths.length; i++) {
if (nativeLibraryPath.equals(paths[i])) {
return;
}
}
String[] paths2 = new String[paths.length+1];
System.arraycopy(paths,0,paths2,0,paths.length);
paths2[paths.length] = nativeLibraryPath;
field.set(null,paths2);
System.setProperty("java.library.path", System.getProperty("java.library.path") + File.pathSeparator + nativeLibraryPath);
} catch (IllegalAccessException e) {
throw new IOException("Failed to get permissions to set library path");
} catch (NoSuchFieldException e) {
throw new IOException("Failed to get field handle to set library path");
}
}


this method should also be added as a way for the "java.library.path" property to find the default natives, as it currently seems to override the current library path, instead of adding the new one.

This is how I use the GAGE natives for the win32 timer.


Title: Re: [RFE] AppletLoader change natives parameters to accept a list of jars
Post by: kappa on January 25, 2011, 01:33:10
Implemented :)

marked as fixed.
Title: Re: [FIXED] AppletLoader change natives parameters to accept a list of jars
Post by: arielsan on January 25, 2011, 01:44:54
Tested!

Thanks.
Title: Re: [FIXED] AppletLoader change natives parameters to accept a list of jars
Post by: kappa on January 25, 2011, 09:40:46
@bobjob, custom natives are already supported and added to 'java.library.path', there was a recent fix  (http://lwjgl.org/forum/index.php/topic,3697.0.html)too, so you should be able to use custom natives with no problems.
Title: Re: [FIXED] AppletLoader change natives parameters to accept a list of jars
Post by: bobjob on January 25, 2011, 11:06:55
oh cool.

the version i of the appletLoader source I checked used this line:
System.setProperty("java.library.path", path + "natives");

has it been fixed not to override the current library paths, so something like:
System.setProperty("java.library.path", System.getProperty("java.library.path") + path + "natives");


Title: Re: [FIXED] AppletLoader change natives parameters to accept a list of jars
Post by: kappa on January 25, 2011, 11:09:46
yes its fixed, see patch from Nate in my previous post.