5

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?

opeongo
  • 384
  • 1
  • 14
  • 4
    You should wait for a new EA build of JDK 9. They decided to allow deep reflective access in JDK 9 by default, so no additional command line arguments will be needed: http://mail.openjdk.java.net/pipermail/jigsaw-dev/2017-May/012673.html. This, however, will change in JDK 10. – ZhekaKozlov May 30 '17 at 04:37

0 Answers0