本文整理汇总了C++中methodHandle::native_function方法的典型用法代码示例。如果您正苦于以下问题:C++ methodHandle::native_function方法的具体用法?C++ methodHandle::native_function怎么用?C++ methodHandle::native_function使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类methodHandle
的用法示例。
在下文中一共展示了methodHandle::native_function方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lookup_critical_style
address NativeLookup::lookup_critical_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style) {
if (!method->has_native_function()) {
return NULL;
}
address current_entry = method->native_function();
char dll_name[JVM_MAXPATHLEN];
int offset;
if (os::dll_address_to_library_name(current_entry, dll_name, sizeof(dll_name), &offset)) {
char ebuf[32];
void* dll = os::dll_load(dll_name, ebuf, sizeof(ebuf));
if (dll != NULL) {
// Compute complete JNI name for style
stringStream st;
if (os_style) os::print_jni_name_prefix_on(&st, args_size);
st.print_raw(pure_name);
st.print_raw(long_name);
if (os_style) os::print_jni_name_suffix_on(&st, args_size);
char* jni_name = st.as_string();
return (address)os::dll_lookup(dll, jni_name);
}
}
return NULL;
}
示例2: lookup
address NativeLookup::lookup(methodHandle method, bool& in_base_library, TRAPS) {
if (!method->has_native_function()) {
address entry = lookup_base(method, in_base_library, CHECK_NULL);
method->set_native_function(entry,
Method::native_bind_event_is_interesting);
// -verbose:jni printing
if (PrintJNIResolving) {
ResourceMark rm(THREAD);
tty->print_cr("[Dynamic-linking native method %s.%s ... JNI]",
method->method_holder()->external_name(),
method->name()->as_C_string());
}
}
return method->native_function();
}
示例3: lookup
/**
* 为给定的本地java方法寻找对应的函数入口地址
*/
address NativeLookup::lookup(methodHandle method, bool& in_base_library, TRAPS) {
if (!method->has_native_function()) {
printf("%s[%d] [tid: %lu]: 试图查找本地方法[%s.%s]..\n", __FILE__, __LINE__, pthread_self(), Klass::cast(method->method_holder())->external_name(), method->name()->as_C_string());
address entry = lookup_base(method, in_base_library, CHECK_NULL);
method->set_native_function(entry, methodOopDesc::native_bind_event_is_interesting);
// -verbose:jni printing
if (PrintJNIResolving) {
ResourceMark rm(THREAD);
tty->print_cr("[Dynamic-linking native method %s.%s ... JNI]",
Klass::cast(method->method_holder())->external_name(),
method->name()->as_C_string());
}
}
return method->native_function();
}