[foreign] RFR 8211060: Library.getDefault() does not work on Windows

Jorn Vernee jbvernee at xs4all.nl
Mon Sep 24 10:52:54 UTC 2018


I'd like to contribute a patch that adds support for the default library 
on windows.

Bug: https://bugs.openjdk.java.net/browse/JDK-8211060

As mentioned before [1], this fixes 2 bugs:

1.) When no library was loaded ClassLoader#NativeLibrary#getFromClass
threw an NPE (at least on windows). That is fixed by returning
defaultLibrary.fromClass when the nativeLibraryContext is empty.

2.) The default library search was not working on windows. It was using
a default handle, which works on unix (dlsym(RTLD_DEFAULT)), but not on
windows (see https://stackoverflow.com/q/23437007). I have changed the
implementation from using a default handle to using a new native
function findEntryInProcess, which does the right thing for Windows
(iterate over all loaded modules), and does the same thing it used to
for unix. findEntry is now a Java method, and the original findEntry is
renamed to findEntry0. The NativeLibrary implementation of findEntry
forwards to findEntry0, and the anonymous class of the default library
overrides to forward to findEntryInProcess.

Please test this patch on unix as well, since I don't have the ability 
to do so.


[1] : 

More information about the panama-dev mailing list