src/share/vm/prims/nativeLookup.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/prims

src/share/vm/prims/nativeLookup.cpp

Print this page




 103   for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
 104   // skip first '('
 105   mangle_name_on(&st, signature, 1, end);
 106   return st.as_string();
 107 }
 108 
 109 extern "C" {
 110   void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls);
 111   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 112   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 113   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
 114 }
 115 
 116 #define CC (char*)  /* cast a literal from (const char*) */
 117 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 118 
 119 static JNINativeMethod lookup_special_native_methods[] = {
 120   { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
 121   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
 122   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
 123   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
 124 };
 125 
 126 static address lookup_special_native(char* jni_name) {
 127   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
 128   for (int i = 0; i < count; i++) {
 129     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 130     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
 131       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
 132     }
 133   }
 134   return NULL;
 135 }
 136 
 137 address NativeLookup::lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS) {
 138   address entry;
 139   // Compute complete JNI name for style
 140   stringStream st;
 141   if (os_style) os::print_jni_name_prefix_on(&st, args_size);
 142   st.print_raw(pure_name);
 143   st.print_raw(long_name);




 103   for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
 104   // skip first '('
 105   mangle_name_on(&st, signature, 1, end);
 106   return st.as_string();
 107 }
 108 
 109 extern "C" {
 110   void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls);
 111   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 112   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 113   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
 114 }
 115 
 116 #define CC (char*)  /* cast a literal from (const char*) */
 117 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 118 
 119 static JNINativeMethod lookup_special_native_methods[] = {
 120   { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
 121   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
 122   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
 123   { CC"Java_jdk_testlib_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
 124 };
 125 
 126 static address lookup_special_native(char* jni_name) {
 127   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
 128   for (int i = 0; i < count; i++) {
 129     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 130     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
 131       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
 132     }
 133   }
 134   return NULL;
 135 }
 136 
 137 address NativeLookup::lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS) {
 138   address entry;
 139   // Compute complete JNI name for style
 140   stringStream st;
 141   if (os_style) os::print_jni_name_prefix_on(&st, args_size);
 142   st.print_raw(pure_name);
 143   st.print_raw(long_name);


src/share/vm/prims/nativeLookup.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File