< prev index next >

src/hotspot/share/prims/nativeLookup.cpp

Print this page




  96 }
  97 
  98 
  99 char* NativeLookup::long_jni_name(const methodHandle& method) {
 100   // Signature ignore the wrapping parenteses and the trailing return type
 101   stringStream st;
 102   Symbol* signature = method->signature();
 103   st.print("__");
 104   // find ')'
 105   int end;
 106   for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
 107   // skip first '('
 108   mangle_name_on(&st, signature, 1, end);
 109   return st.as_string();
 110 }
 111 
 112 extern "C" {
 113   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 114   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 115   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);

 116 #if INCLUDE_JVMCI
 117   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
 118   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
 119 #endif
 120 }
 121 
 122 #define CC (char*)  /* cast a literal from (const char*) */
 123 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 124 
 125 static JNINativeMethod lookup_special_native_methods[] = {
 126   { CC"Java_jdk_internal_misc_Unsafe_registerNatives",             NULL, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) },
 127   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
 128   { CC"Java_jdk_internal_perf_Perf_registerNatives",               NULL, FN_PTR(JVM_RegisterPerfMethods)         },
 129   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },

 130 #if INCLUDE_JVMCI
 131   { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime",            NULL, FN_PTR(JVM_GetJVMCIRuntime)             },
 132   { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives",       NULL, FN_PTR(JVM_RegisterJVMCINatives)        },
 133 #endif
 134 #if INCLUDE_TRACE
 135   { CC"Java_jdk_jfr_internal_JVM_registerNatives",                 NULL, TRACE_REGISTER_NATIVES                  },
 136 #endif
 137 };
 138 
 139 static address lookup_special_native(char* jni_name) {
 140   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
 141   for (int i = 0; i < count; i++) {
 142     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 143     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
 144       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
 145     }
 146   }
 147   return NULL;
 148 }
 149 




  96 }
  97 
  98 
  99 char* NativeLookup::long_jni_name(const methodHandle& method) {
 100   // Signature ignore the wrapping parenteses and the trailing return type
 101   stringStream st;
 102   Symbol* signature = method->signature();
 103   st.print("__");
 104   // find ')'
 105   int end;
 106   for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
 107   // skip first '('
 108   mangle_name_on(&st, signature, 1, end);
 109   return st.as_string();
 110 }
 111 
 112 extern "C" {
 113   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 114   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 115   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
 116 // void JNICALL JVM_RegisterContinuationMethods(JNIEnv *env, jclass cls);
 117 #if INCLUDE_JVMCI
 118   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
 119   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
 120 #endif
 121 }
 122 
 123 #define CC (char*)  /* cast a literal from (const char*) */
 124 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 125 
 126 static JNINativeMethod lookup_special_native_methods[] = {
 127   { CC"Java_jdk_internal_misc_Unsafe_registerNatives",             NULL, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) },
 128   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
 129   { CC"Java_jdk_internal_perf_Perf_registerNatives",               NULL, FN_PTR(JVM_RegisterPerfMethods)         },
 130   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
 131 // { CC"Java_java_lang_Continuation_registerNatives",               NULL, FN_PTR(JVM_RegisterContinuationMethods) },
 132 #if INCLUDE_JVMCI
 133   { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime",            NULL, FN_PTR(JVM_GetJVMCIRuntime)             },
 134   { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives",       NULL, FN_PTR(JVM_RegisterJVMCINatives)        },
 135 #endif
 136 #if INCLUDE_TRACE
 137   { CC"Java_jdk_jfr_internal_JVM_registerNatives",                 NULL, TRACE_REGISTER_NATIVES                  },
 138 #endif
 139 };
 140 
 141 static address lookup_special_native(char* jni_name) {
 142   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
 143   for (int i = 0; i < count; i++) {
 144     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 145     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
 146       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
 147     }
 148   }
 149   return NULL;
 150 }
 151 


< prev index next >