lundi 29 mai 2017

Adding new paths for native libraries at runtime in Java9

I have an app that includes some native code. In an effort to make things easy for users to install and run, I have been extending the private field ClassLoader.sys_paths at runtime as described in this previous question: Adding new paths for native libraries at runtime in Java. With this hack the app can run with a simple unadorned java -jar app.jar command and the native objects will be located correctly in the installation directory.

This technique no longer works in Java 9 (see How to solve InaccessibleObjectException ("Unable to make {member} accessible: module {A} does not 'opens {package}' to {B}") on Java 9?). This article describes the changes to Java 9 and suggests a solution (adding arguments to the command line to open the module), but this defeats my original intent of allowing a simple execution of the java command.

Is there any way to change the native library search path at runtime, or is this considered too much of a loaded gun to leave lying around?





Aucun commentaire:

Enregistrer un commentaire