基本的には, 各 OS が提供しているダイナミックロード用のシステムコールを呼び出すだけ.
なお, JNI_OnLoad() シンボルが含まれている場合には, それを呼び出す処理も行われる.
JNI_OnLoad のシンボル名は, プラットフォームによっては (より具体的に言うと Windows の場合には) 複数の候補が存在することがある.
((cite: hotspot/src/os/windows/vm/jvm_windows.h))
#define JNI_ONLOAD_SYMBOLS {"_JNI_OnLoad@8", "JNI_OnLoad"}
java.lang.System.loadLibrary()
-> java.lang.Runtime.loadLibrary0()
-> java.lang.ClassLoader.loadLibrary()
-> java.lang.ClassLoader.findLibrary() (<= 必要に応じて呼び出される)
-> java.lang.ClassLoader.loadLibrary0()
-> java.lang.ClassLoader$NativeLibrary.load()
-> Java_java_lang_ClassLoader_00024NativeLibrary_load()
-> (1) ライブラリをロードする.
-> JVM_LoadLibrary()
-> os::dll_load()
* Linux の場合
-> dlopen()
* Solaris の場合
-> dlopen()
* Windows の場合
-> LoadLibrary()
(1) もし JNI_OnLoad シンボルが含まれていればそれを呼び出す.
-> JVM_FindLibraryEntry()
-> os::dll_lookup()
* Linux の場合
-> dlsym()
* Solaris の場合
-> dlsym()
* Windows の場合
-> GetProcAddress()
(1) ロードしたライブラリの JNI version をチェックする.
-> JVM_IsSupportedJNIVersion()
-> Threads::is_supported_jni_version_including_1_1()
-> Threads::is_supported_jni_version()
(1) もし何かエラーが発生していたり, jni version が合わなかった場合はアンロード.
-> JVM_UnloadLibrary()
-> os::dll_unload()
* Linux の場合
-> dlclose()
* Solaris の場合
-> dlclose()
* Windows の場合
-> FreeLibrary()
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
(#Under Construction)
(#Under Construction)
See: here for details
See: here for details
(#Under Construction)
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
See: here for details
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.