RFR: 8266310: deadlock while loading the JNI code
Mandy Chung
mandy.chung at oracle.com
Thu May 13 21:20:09 UTC 2021
On 5/13/21 6:05 AM, David Holmes wrote:
> Not every problem has a solution :) If JNI_OnLoad has to execute
> atomically with respect to loading a library then there will always be
> a deadlock potential. The only complete solution would not hold a lock
> while JNI_OnLoad is executed, but that completely changes the
> semantics of native library loading.
I have been giving some thought on this issue. I agree with David that
we should look into a solution not holding a lock while JNI_OnLoad is
executed. It might be possible to put all threads that trying to load
the same native library that is being loaded to wait and only one thread
is loading it and executing JNI_OnLoad (e.g. add a state in
NativeLibrary to indicate it is being loaded, already loaded, being
unloaded). I haven't had the cycle to think through it in details though.
Mandy
More information about the core-libs-dev
mailing list