ClassLoader.loadLibrary NullPointerException Regression in 8u242

Laurent Goubet laurent.goubet at
Wed Mar 4 09:23:32 UTC 2020


Sorry, this is supposed to be an answer to the following thread but I 
don't know if it is possible for me to answer a thread that existed 
before I joined the mailing list :

I am also reproducing this issue when running my product on an OpenJDK 
and I wanted to give you a background on why the ClassLoader.sys_paths 
can be set to "null" through reflection.

The very root cause of this is due to implementers that need to update 
the java library path at runtime for one reason or another. Oracle JDK 
does not support this because of a cache in the ClassLoader (usr_paths) 
that is initialized to the value of "java.library.path" when the VM 
runs, and never updated _unless_ sys_paths is null. So if I want to use 
System.getProperty("java.library.path") + File.pathSeparator 
+"my/library/path")" and then use System.loadLibrary(...) to get a 
library in that new path I've added, my only way is to reset 
ClassLoader.sys_paths to null.

This is actually a workaround that had been initially shared by a Sun 
engineer (apparently) at ... The forum no 
longer exists at that url and I haven't found a cache anywhere, but 
simply searching for that url on google will return a few results of 
people copy/pasting the comment about the source of the workaround... I 
guess there are a lot more programs using that workaround without citing 
the source.

This is an implementation detail, but it seems to be used by quite a few 
people to force the JDK to reset its library path, so it would be nice 
for OpenJDK to support that as well instead of failing in NPE.



*Laurent Goubet*
+33 2 51 13 51 42


7 Boulevard Ampère - Carquefou - France
** <> | *twitter* 
<> | *linkedin* 

More information about the jdk8u-dev mailing list