If I stepped through the execution with the debuger everything would be fine. Does this imply that the dll load is async and one should wait some time before trying to reference it?
I’ve opted for catching the “UnsatisfiedLinkError” during the ModuleHook.setup() instead of unloading the library during ModuleHook.shutdown().
Using a native library in your module is opening a can of worms. Java 11+ should unload the library once the ClassLoader that loaded it has been garbage collected but this can take some time and you don't know when it has happened.
In the past we've simply considered modules that load a native library to be "one and done" - they can't be restarted - but there is not a way to actually prevent that from happening.
Bingo. I fought this loading OpenCV for quite a bit. I peeked at the disassembly of IA's JNI resource loading helper to discover that you can get around the problem with a temporary file and unique file name. As long as it is a new classloader, which it will be in a module context, it won't clash.