Hello Guest

[FIXED] AppletLoader change natives parameters to accept a list of jars

  • 6 Replies
  • 5578 Views
It could be really helpful to treat the natives parameters like the jars parameters, a list of items separated by ','

An example:

Code: [Select]
<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.

*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
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).
Code: [Select]
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.


« Last Edit: January 24, 2011, 23:03:30 by bobjob »

*

Offline kappa

  • *****
  • 1313
Implemented :)

marked as fixed.

Tested!

Thanks.

*

Offline kappa

  • *****
  • 1313
@bobjob, custom natives are already supported and added to 'java.library.path', there was a recent fix too, so you should be able to use custom natives with no problems.

*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
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");



*

Offline kappa

  • *****
  • 1313
yes its fixed, see patch from Nate in my previous post.
« Last Edit: January 25, 2011, 11:11:31 by kappa »