Top


定義場所(file name)

hotspot/src/share/vm/runtime/os.cpp

名前(function name)

void* os::native_java_library() {

本体部(body)

  {- -------------------------------------------
  (1) もしまだ libjava をロードしていなければロードする.
      (なお, 1.3 では libjava が libverify に依存しているため, 先に libverify もロードしている)
      ---------------------------------------- -}

      if (_native_java_library == NULL) {
        char buffer[JVM_MAXPATHLEN];
        char ebuf[1024];

        // Try to load verify dll first. In 1.3 java dll depends on it and is not
        // always able to find it when the loading executable is outside the JDK.
        // In order to keep working with 1.2 we ignore any loading errors.
        dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify");
        dll_load(buffer, ebuf, sizeof(ebuf));

        // Load java dll
        dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "java");
        _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf));
        if (_native_java_library == NULL) {
          vm_exit_during_initialization("Unable to load native library", ebuf);
        }
      }

  {- -------------------------------------------
  (1) ?? (条件逆じゃないか? #TODO)
      まだ libjava の JNI_OnLoad() を呼び出していない場合,  
      ThreadLocalStorage の初期化が完了していれば, JNI_OnLoad() の呼び出し処理を行う.
      ---------------------------------------- -}

      static jboolean onLoaded = JNI_FALSE;
      if (onLoaded) {
        // We may have to wait to fire OnLoad until TLS is initialized.
        if (ThreadLocalStorage::is_initialized()) {
          // The JNI_OnLoad handling is normally done by method load in
          // java.lang.ClassLoader$NativeLibrary, but the VM loads the base library
          // explicitly so we have to check for JNI_OnLoad as well
          const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
          JNI_OnLoad_t JNI_OnLoad = CAST_TO_FN_PTR(
              JNI_OnLoad_t, dll_lookup(_native_java_library, onLoadSymbols[0]));
          if (JNI_OnLoad != NULL) {
            JavaThread* thread = JavaThread::current();
            ThreadToNativeFromVM ttn(thread);
            HandleMark hm(thread);
            jint ver = (*JNI_OnLoad)(&main_vm, NULL);
            onLoaded = JNI_TRUE;
            if (!Threads::is_supported_jni_version_including_1_1(ver)) {
              vm_exit_during_initialization("Unsupported JNI version");
            }
          }
        }
      }

  {- -------------------------------------------
  (1) libjava へのポインタをリターンする
      ---------------------------------------- -}

      return _native_java_library;
    }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.