hotspot/src/share/vm/prims/nativeLookup.cpp
changeset 13728 882756847a04
parent 13396 1b2b5f740ee0
child 13975 2f7431485cfa
equal deleted inserted replaced
13727:caf5eb7dd4a7 13728:882756847a04
    28 #include "classfile/vmSymbols.hpp"
    28 #include "classfile/vmSymbols.hpp"
    29 #include "memory/oopFactory.hpp"
    29 #include "memory/oopFactory.hpp"
    30 #include "memory/resourceArea.hpp"
    30 #include "memory/resourceArea.hpp"
    31 #include "memory/universe.inline.hpp"
    31 #include "memory/universe.inline.hpp"
    32 #include "oops/instanceKlass.hpp"
    32 #include "oops/instanceKlass.hpp"
    33 #include "oops/methodOop.hpp"
    33 #include "oops/method.hpp"
    34 #include "oops/oop.inline.hpp"
    34 #include "oops/oop.inline.hpp"
    35 #include "oops/symbol.hpp"
    35 #include "oops/symbol.hpp"
    36 #include "prims/jvm_misc.hpp"
    36 #include "prims/jvm_misc.hpp"
    37 #include "prims/nativeLookup.hpp"
    37 #include "prims/nativeLookup.hpp"
    38 #include "runtime/arguments.hpp"
    38 #include "runtime/arguments.hpp"
   164   // the native Java library. This takes care of any bootstrapping problems.
   164   // the native Java library. This takes care of any bootstrapping problems.
   165   // Note: It is critical for bootstrapping that Java_java_lang_ClassLoader_00024NativeLibrary_find
   165   // Note: It is critical for bootstrapping that Java_java_lang_ClassLoader_00024NativeLibrary_find
   166   // gets found the first time around - otherwise an infinite loop can occure. This is
   166   // gets found the first time around - otherwise an infinite loop can occure. This is
   167   // another VM/library dependency
   167   // another VM/library dependency
   168   Handle loader(THREAD,
   168   Handle loader(THREAD,
   169                 instanceKlass::cast(method->method_holder())->class_loader());
   169                 InstanceKlass::cast(method->method_holder())->class_loader());
   170   if (loader.is_null()) {
   170   if (loader.is_null()) {
   171     entry = lookup_special_native(jni_name);
   171     entry = lookup_special_native(jni_name);
   172     if (entry == NULL) {
   172     if (entry == NULL) {
   173        entry = (address) os::dll_lookup(os::native_java_library(), jni_name);
   173        entry = (address) os::dll_lookup(os::native_java_library(), jni_name);
   174     }
   174     }
   347     // we have a name for a wrapping method
   347     // we have a name for a wrapping method
   348     int wrapper_name_len = (int)strlen(wrapper_name);
   348     int wrapper_name_len = (int)strlen(wrapper_name);
   349     TempNewSymbol wrapper_symbol = SymbolTable::probe(wrapper_name, wrapper_name_len);
   349     TempNewSymbol wrapper_symbol = SymbolTable::probe(wrapper_name, wrapper_name_len);
   350     if (wrapper_symbol != NULL) {
   350     if (wrapper_symbol != NULL) {
   351       KlassHandle kh(method->method_holder());
   351       KlassHandle kh(method->method_holder());
   352       methodOop wrapper_method = Klass::cast(kh())->lookup_method(wrapper_symbol,
   352       Method* wrapper_method = Klass::cast(kh())->lookup_method(wrapper_symbol,
   353                                                                   method->signature());
   353                                                                   method->signature());
   354       if (wrapper_method != NULL && !wrapper_method->is_native()) {
   354       if (wrapper_method != NULL && !wrapper_method->is_native()) {
   355         // we found a wrapper method, use its native entry
   355         // we found a wrapper method, use its native entry
   356         method->set_is_prefixed_native();
   356         method->set_is_prefixed_native();
   357         return lookup_entry(wrapper_method, in_base_library, THREAD);
   357         return lookup_entry(wrapper_method, in_base_library, THREAD);
   384     address entry =
   384     address entry =
   385         method->intrinsic_id() == vmIntrinsics::_invokeGeneric ?
   385         method->intrinsic_id() == vmIntrinsics::_invokeGeneric ?
   386             SharedRuntime::native_method_throw_unsupported_operation_exception_entry() :
   386             SharedRuntime::native_method_throw_unsupported_operation_exception_entry() :
   387             lookup_base(method, in_base_library, CHECK_NULL);
   387             lookup_base(method, in_base_library, CHECK_NULL);
   388     method->set_native_function(entry,
   388     method->set_native_function(entry,
   389       methodOopDesc::native_bind_event_is_interesting);
   389       Method::native_bind_event_is_interesting);
   390     // -verbose:jni printing
   390     // -verbose:jni printing
   391     if (PrintJNIResolving) {
   391     if (PrintJNIResolving) {
   392       ResourceMark rm(THREAD);
   392       ResourceMark rm(THREAD);
   393       tty->print_cr("[Dynamic-linking native method %s.%s ... JNI]",
   393       tty->print_cr("[Dynamic-linking native method %s.%s ... JNI]",
   394         Klass::cast(method->method_holder())->external_name(),
   394         Klass::cast(method->method_holder())->external_name(),
   404   TempNewSymbol c_name = SymbolTable::new_symbol(class_name,  CATCH);
   404   TempNewSymbol c_name = SymbolTable::new_symbol(class_name,  CATCH);
   405   TempNewSymbol m_name = SymbolTable::new_symbol(method_name, CATCH);
   405   TempNewSymbol m_name = SymbolTable::new_symbol(method_name, CATCH);
   406   TempNewSymbol s_name = SymbolTable::new_symbol(signature,   CATCH);
   406   TempNewSymbol s_name = SymbolTable::new_symbol(signature,   CATCH);
   407 
   407 
   408   // Find the class
   408   // Find the class
   409   klassOop k = SystemDictionary::resolve_or_fail(c_name, true, CATCH);
   409   Klass* k = SystemDictionary::resolve_or_fail(c_name, true, CATCH);
   410   instanceKlassHandle klass (THREAD, k);
   410   instanceKlassHandle klass (THREAD, k);
   411 
   411 
   412   // Find method and invoke standard lookup
   412   // Find method and invoke standard lookup
   413   methodHandle method (THREAD,
   413   methodHandle method (THREAD,
   414                        klass->uncached_lookup_method(m_name, s_name));
   414                        klass->uncached_lookup_method(m_name, s_name));