hotspot/src/share/vm/runtime/os.cpp
changeset 950 6112b627bb36
parent 823 9a5271881bc0
child 1664 fc9ed50498fb
equal deleted inserted replaced
823:9a5271881bc0 950:6112b627bb36
   334 void* os::native_java_library() {
   334 void* os::native_java_library() {
   335   if (_native_java_library == NULL) {
   335   if (_native_java_library == NULL) {
   336     char buffer[JVM_MAXPATHLEN];
   336     char buffer[JVM_MAXPATHLEN];
   337     char ebuf[1024];
   337     char ebuf[1024];
   338 
   338 
   339     // Try to load verify dll first. In 1.3 java dll depends on it and is not always
   339     // Try to load verify dll first. In 1.3 java dll depends on it and is not
   340     // able to find it when the loading executable is outside the JDK.
   340     // always able to find it when the loading executable is outside the JDK.
   341     // In order to keep working with 1.2 we ignore any loading errors.
   341     // In order to keep working with 1.2 we ignore any loading errors.
   342     hpi::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify");
   342     dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify");
   343     hpi::dll_load(buffer, ebuf, sizeof(ebuf));
   343     dll_load(buffer, ebuf, sizeof(ebuf));
   344 
   344 
   345     // Load java dll
   345     // Load java dll
   346     hpi::dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "java");
   346     dll_build_name(buffer, sizeof(buffer), Arguments::get_dll_dir(), "java");
   347     _native_java_library = hpi::dll_load(buffer, ebuf, sizeof(ebuf));
   347     _native_java_library = dll_load(buffer, ebuf, sizeof(ebuf));
   348     if (_native_java_library == NULL) {
   348     if (_native_java_library == NULL) {
   349       vm_exit_during_initialization("Unable to load native library", ebuf);
   349       vm_exit_during_initialization("Unable to load native library", ebuf);
   350     }
   350     }
   351     // The JNI_OnLoad handling is normally done by method load in java.lang.ClassLoader$NativeLibrary,
   351   }
   352     // but the VM loads the base library explicitly so we have to check for JNI_OnLoad as well
   352   static jboolean onLoaded = JNI_FALSE;
   353     const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
   353   if (onLoaded) {
   354     JNI_OnLoad_t JNI_OnLoad = CAST_TO_FN_PTR(JNI_OnLoad_t, hpi::dll_lookup(_native_java_library, onLoadSymbols[0]));
   354     // We may have to wait to fire OnLoad until TLS is initialized.
   355     if (JNI_OnLoad != NULL) {
   355     if (ThreadLocalStorage::is_initialized()) {
   356       JavaThread* thread = JavaThread::current();
   356       // The JNI_OnLoad handling is normally done by method load in
   357       ThreadToNativeFromVM ttn(thread);
   357       // java.lang.ClassLoader$NativeLibrary, but the VM loads the base library
   358       HandleMark hm(thread);
   358       // explicitly so we have to check for JNI_OnLoad as well
   359       jint ver = (*JNI_OnLoad)(&main_vm, NULL);
   359       const char *onLoadSymbols[] = JNI_ONLOAD_SYMBOLS;
   360       if (!Threads::is_supported_jni_version_including_1_1(ver)) {
   360       JNI_OnLoad_t JNI_OnLoad = CAST_TO_FN_PTR(
   361         vm_exit_during_initialization("Unsupported JNI version");
   361           JNI_OnLoad_t, dll_lookup(_native_java_library, onLoadSymbols[0]));
       
   362       if (JNI_OnLoad != NULL) {
       
   363         JavaThread* thread = JavaThread::current();
       
   364         ThreadToNativeFromVM ttn(thread);
       
   365         HandleMark hm(thread);
       
   366         jint ver = (*JNI_OnLoad)(&main_vm, NULL);
       
   367         onLoaded = JNI_TRUE;
       
   368         if (!Threads::is_supported_jni_version_including_1_1(ver)) {
       
   369           vm_exit_during_initialization("Unsupported JNI version");
       
   370         }
   362       }
   371       }
   363     }
   372     }
   364   }
   373   }
   365   return _native_java_library;
   374   return _native_java_library;
   366 }
   375 }