src/share/vm/runtime/os.cpp

changeset 677
d95b224e9f17
parent 672
1fdb98a17101
child 912
24fda36852ce
     1.1 --- a/src/share/vm/runtime/os.cpp	Sat Jul 19 17:38:22 2008 -0400
     1.2 +++ b/src/share/vm/runtime/os.cpp	Mon Jul 28 14:07:44 2008 -0400
     1.3 @@ -336,29 +336,38 @@
     1.4      char buffer[JVM_MAXPATHLEN];
     1.5      char ebuf[1024];
     1.6  
     1.7 -    // Try to load verify dll first. In 1.3 java dll depends on it and is not always
     1.8 -    // able to find it when the loading executable is outside the JDK.
     1.9 +    // Try to load verify dll first. In 1.3 java dll depends on it and is not
    1.10 +    // always able to find it when the loading executable is outside the JDK.
    1.11      // In order to keep working with 1.2 we ignore any loading errors.
    1.12 -    hpi::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify");
    1.13 -    hpi::dll_load(buffer, ebuf, sizeof(ebuf));
    1.14 +    dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify");
    1.15 +    dll_load(buffer, ebuf, sizeof(ebuf));
    1.16  
    1.17      // Load java dll
    1.18 -    hpi::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "java");
    1.19 -    _native_java_library = hpi::dll_load(buffer, ebuf, sizeof(ebuf));
    1.20 +    dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "java");
    1.21 +    _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf));
    1.22      if (_native_java_library == NULL) {
    1.23        vm_exit_during_initialization("Unable to load native library", ebuf);
    1.24      }
    1.25 -    // The JNI_OnLoad handling is normally done by method load in java.lang.ClassLoader$NativeLibrary,
    1.26 -    // but the VM loads the base library explicitly so we have to check for JNI_OnLoad as well
    1.27 -    const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
    1.28 -    JNI_OnLoad_t JNI_OnLoad = CAST_TO_FN_PTR(JNI_OnLoad_t, hpi::dll_lookup(_native_java_library, onLoadSymbols[0]));
    1.29 -    if (JNI_OnLoad != NULL) {
    1.30 -      JavaThread* thread = JavaThread::current();
    1.31 -      ThreadToNativeFromVM ttn(thread);
    1.32 -      HandleMark hm(thread);
    1.33 -      jint ver = (*JNI_OnLoad)(&main_vm, NULL);
    1.34 -      if (!Threads::is_supported_jni_version_including_1_1(ver)) {
    1.35 -        vm_exit_during_initialization("Unsupported JNI version");
    1.36 +  }
    1.37 +  static jboolean onLoaded = JNI_FALSE;
    1.38 +  if (onLoaded) {
    1.39 +    // We may have to wait to fire OnLoad until TLS is initialized.
    1.40 +    if (ThreadLocalStorage::is_initialized()) {
    1.41 +      // The JNI_OnLoad handling is normally done by method load in
    1.42 +      // java.lang.ClassLoader$NativeLibrary, but the VM loads the base library
    1.43 +      // explicitly so we have to check for JNI_OnLoad as well
    1.44 +      const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
    1.45 +      JNI_OnLoad_t JNI_OnLoad = CAST_TO_FN_PTR(
    1.46 +          JNI_OnLoad_t, dll_lookup(_native_java_library, onLoadSymbols[0]));
    1.47 +      if (JNI_OnLoad != NULL) {
    1.48 +        JavaThread* thread = JavaThread::current();
    1.49 +        ThreadToNativeFromVM ttn(thread);
    1.50 +        HandleMark hm(thread);
    1.51 +        jint ver = (*JNI_OnLoad)(&main_vm, NULL);
    1.52 +        onLoaded = JNI_TRUE;
    1.53 +        if (!Threads::is_supported_jni_version_including_1_1(ver)) {
    1.54 +          vm_exit_during_initialization("Unsupported JNI version");
    1.55 +        }
    1.56        }
    1.57      }
    1.58    }

mercurial