< prev index next >

src/hotspot/share/prims/nativeLookup.cpp

Print this page

186   // Signatures ignore the wrapping parentheses and the trailing return type
187   stringStream st;
188   Symbol* signature = method->signature();
189   st.print("__");
190   // find ')'
191   int end;
192   for (end = 0; end < signature->utf8_length() && signature->char_at(end) != JVM_SIGNATURE_ENDFUNC; end++);
193   // skip first '('
194   if (!map_escaped_name_on(&st, signature, 1, end)) {
195     return NULL;
196   }
197 
198   return st.as_string();
199 }
200 
201 extern "C" {
202   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
203   void JNICALL JVM_RegisterReferencesMethods(JNIEnv *env, jclass unsafecls);
204   void JNICALL JVM_RegisterUpcallHandlerMethods(JNIEnv *env, jclass unsafecls);
205   void JNICALL JVM_RegisterProgrammableUpcallHandlerMethods(JNIEnv *env, jclass unsafecls);
206   void JNICALL JVM_RegisterProgrammableInvokerMethods(JNIEnv *env, jclass unsafecls);
207   void JNICALL JVM_RegisterNativeEntryPointMethods(JNIEnv *env, jclass unsafecls);
208   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
209   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
210   void JNICALL JVM_RegisterVectorSupportMethods(JNIEnv *env, jclass vsclass);
211 #if INCLUDE_JVMCI
212   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
213   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
214 #endif
215 }
216 
217 #define CC (char*)  /* cast a literal from (const char*) */
218 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
219 
220 static JNINativeMethod lookup_special_native_methods[] = {
221   { CC"Java_jdk_internal_misc_Unsafe_registerNatives",             NULL, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) },
222   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
223   { CC"Java_jdk_internal_foreign_abi_UpcallStubs_registerNatives",      NULL, FN_PTR(JVM_RegisterUpcallHandlerMethods) },
224   { CC"Java_jdk_internal_foreign_abi_ProgrammableUpcallHandler_registerNatives",      NULL, FN_PTR(JVM_RegisterProgrammableUpcallHandlerMethods) },
225   { CC"Java_jdk_internal_foreign_abi_ProgrammableInvoker_registerNatives",      NULL, FN_PTR(JVM_RegisterProgrammableInvokerMethods) },
226   { CC"Java_jdk_internal_invoke_NativeEntryPoint_registerNatives",      NULL, FN_PTR(JVM_RegisterNativeEntryPointMethods) },
227   { CC"Java_jdk_internal_perf_Perf_registerNatives",               NULL, FN_PTR(JVM_RegisterPerfMethods)         },
228   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
229   { CC"Java_jdk_test_whitebox_WhiteBox_registerNatives",           NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
230   { CC"Java_jdk_internal_vm_vector_VectorSupport_registerNatives", NULL, FN_PTR(JVM_RegisterVectorSupportMethods)},
231 #if INCLUDE_JVMCI
232   { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime",            NULL, FN_PTR(JVM_GetJVMCIRuntime)             },
233   { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives",       NULL, FN_PTR(JVM_RegisterJVMCINatives)        },
234 #endif
235 #if INCLUDE_JFR
236   { CC"Java_jdk_jfr_internal_JVM_registerNatives",                 NULL, FN_PTR(jfr_register_natives)            },
237 #endif
238   { CC"Java_jdk_internal_misc_ScopedMemoryAccess_registerNatives", NULL, FN_PTR(JVM_RegisterJDKInternalMiscScopedMemoryAccessMethods) },
239 };
240 
241 static address lookup_special_native(const char* jni_name) {
242   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
243   for (int i = 0; i < count; i++) {
244     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
245     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {

186   // Signatures ignore the wrapping parentheses and the trailing return type
187   stringStream st;
188   Symbol* signature = method->signature();
189   st.print("__");
190   // find ')'
191   int end;
192   for (end = 0; end < signature->utf8_length() && signature->char_at(end) != JVM_SIGNATURE_ENDFUNC; end++);
193   // skip first '('
194   if (!map_escaped_name_on(&st, signature, 1, end)) {
195     return NULL;
196   }
197 
198   return st.as_string();
199 }
200 
201 extern "C" {
202   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
203   void JNICALL JVM_RegisterReferencesMethods(JNIEnv *env, jclass unsafecls);
204   void JNICALL JVM_RegisterUpcallHandlerMethods(JNIEnv *env, jclass unsafecls);
205   void JNICALL JVM_RegisterProgrammableUpcallHandlerMethods(JNIEnv *env, jclass unsafecls);

206   void JNICALL JVM_RegisterNativeEntryPointMethods(JNIEnv *env, jclass unsafecls);
207   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
208   void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
209   void JNICALL JVM_RegisterVectorSupportMethods(JNIEnv *env, jclass vsclass);
210 #if INCLUDE_JVMCI
211   jobject  JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
212   void     JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
213 #endif
214 }
215 
216 #define CC (char*)  /* cast a literal from (const char*) */
217 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
218 
219 static JNINativeMethod lookup_special_native_methods[] = {
220   { CC"Java_jdk_internal_misc_Unsafe_registerNatives",             NULL, FN_PTR(JVM_RegisterJDKInternalMiscUnsafeMethods) },
221   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
222   { CC"Java_jdk_internal_foreign_abi_UpcallStubs_registerNatives",      NULL, FN_PTR(JVM_RegisterUpcallHandlerMethods) },
223   { CC"Java_jdk_internal_foreign_abi_ProgrammableUpcallHandler_registerNatives",      NULL, FN_PTR(JVM_RegisterProgrammableUpcallHandlerMethods) },

224   { CC"Java_jdk_internal_invoke_NativeEntryPoint_registerNatives",      NULL, FN_PTR(JVM_RegisterNativeEntryPointMethods) },
225   { CC"Java_jdk_internal_perf_Perf_registerNatives",               NULL, FN_PTR(JVM_RegisterPerfMethods)         },
226   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
227   { CC"Java_jdk_test_whitebox_WhiteBox_registerNatives",           NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
228   { CC"Java_jdk_internal_vm_vector_VectorSupport_registerNatives", NULL, FN_PTR(JVM_RegisterVectorSupportMethods)},
229 #if INCLUDE_JVMCI
230   { CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime",            NULL, FN_PTR(JVM_GetJVMCIRuntime)             },
231   { CC"Java_jdk_vm_ci_hotspot_CompilerToVM_registerNatives",       NULL, FN_PTR(JVM_RegisterJVMCINatives)        },
232 #endif
233 #if INCLUDE_JFR
234   { CC"Java_jdk_jfr_internal_JVM_registerNatives",                 NULL, FN_PTR(jfr_register_natives)            },
235 #endif
236   { CC"Java_jdk_internal_misc_ScopedMemoryAccess_registerNatives", NULL, FN_PTR(JVM_RegisterJDKInternalMiscScopedMemoryAccessMethods) },
237 };
238 
239 static address lookup_special_native(const char* jni_name) {
240   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
241   for (int i = 0; i < count; i++) {
242     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
243     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
< prev index next >