src/hotspot/share/prims/nativeLookup.cpp
changeset 48302 50181ff45d46
parent 47782 d099408b386e
child 49359 59f6547e151f
equal deleted inserted replaced
48301:32f13c6c1bbd 48302:50181ff45d46
   222       if (os_style) os::print_jni_name_prefix_on(&st, args_size);
   222       if (os_style) os::print_jni_name_prefix_on(&st, args_size);
   223       st.print_raw(pure_name);
   223       st.print_raw(pure_name);
   224       st.print_raw(long_name);
   224       st.print_raw(long_name);
   225       if (os_style) os::print_jni_name_suffix_on(&st, args_size);
   225       if (os_style) os::print_jni_name_suffix_on(&st, args_size);
   226       char* jni_name = st.as_string();
   226       char* jni_name = st.as_string();
   227       return (address)os::dll_lookup(dll, jni_name);
   227       address critical_entry = (address)os::dll_lookup(dll, jni_name);
       
   228       // Close the handle to avoid keeping the library alive if the native method holder is unloaded.
       
   229       // This is fine because the library is still kept alive by JNI (see JVM_LoadLibrary). As soon
       
   230       // as the holder class and the library are unloaded (see JVM_UnloadLibrary), the native wrapper
       
   231       // that calls 'critical_entry' becomes unreachable and is unloaded as well.
       
   232       os::dll_unload(dll);
       
   233       return critical_entry;
   228     }
   234     }
   229   }
   235   }
   230 
   236 
   231   return NULL;
   237   return NULL;
   232 }
   238 }
   242 
   248 
   243   // Compute argument size
   249   // Compute argument size
   244   int args_size = 1                             // JNIEnv
   250   int args_size = 1                             // JNIEnv
   245                 + (method->is_static() ? 1 : 0) // class for static methods
   251                 + (method->is_static() ? 1 : 0) // class for static methods
   246                 + method->size_of_parameters(); // actual parameters
   252                 + method->size_of_parameters(); // actual parameters
   247 
       
   248 
   253 
   249   // 1) Try JNI short style
   254   // 1) Try JNI short style
   250   entry = lookup_style(method, pure_name, "",        args_size, true,  in_base_library, CHECK_NULL);
   255   entry = lookup_style(method, pure_name, "",        args_size, true,  in_base_library, CHECK_NULL);
   251   if (entry != NULL) return entry;
   256   if (entry != NULL) return entry;
   252 
   257