src/share/vm/prims/nativeLookup.cpp

Print this page




 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 #if INCLUDE_JVMCI
 115   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
 116   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
 117 #endif
 118 }
 119 
 120 #define CC (char*)  /* cast a literal from (const char*) */
 121 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 122 
 123 static JNINativeMethod lookup_special_native_methods[] = {

 124   { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
 125   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
 126   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
 127   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
 128 #if INCLUDE_JVMCI
 129   { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime",            NULL, FN_PTR(JVM_GetJVMCIRuntime)             },
 130   { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives",       NULL, FN_PTR(JVM_RegisterJVMCINatives)        },
 131 #endif
 132 };
 133 
 134 static address lookup_special_native(char* jni_name) {
 135   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
 136   for (int i = 0; i < count; i++) {
 137     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 138     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
 139       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
 140     }
 141   }
 142   return NULL;
 143 }




 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 #if INCLUDE_JVMCI
 115   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
 116   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
 117 #endif
 118 }
 119 
 120 #define CC (char*)  /* cast a literal from (const char*) */
 121 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 122 
 123 static JNINativeMethod lookup_special_native_methods[] = {
 124   { CC"Java_jdk_internal_misc_Unsafe_registerNatives",             NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
 125   { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
 126   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
 127   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
 128   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
 129 #if INCLUDE_JVMCI
 130   { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime",            NULL, FN_PTR(JVM_GetJVMCIRuntime)             },
 131   { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives",       NULL, FN_PTR(JVM_RegisterJVMCINatives)        },
 132 #endif
 133 };
 134 
 135 static address lookup_special_native(char* jni_name) {
 136   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
 137   for (int i = 0; i < count; i++) {
 138     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 139     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
 140       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
 141     }
 142   }
 143   return NULL;
 144 }