< prev index next >

src/share/vm/prims/nativeLookup.cpp

Print this page




  94 
  95 
  96 char* NativeLookup::long_jni_name(methodHandle method) {
  97   // Signature ignore the wrapping parenteses and the trailing return type
  98   stringStream st;
  99   Symbol* signature = method->signature();
 100   st.print("__");
 101   // find ')'
 102   int end;
 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);




  94 
  95 
  96 char* NativeLookup::long_jni_name(methodHandle method) {
  97   // Signature ignore the wrapping parenteses and the trailing return type
  98   stringStream st;
  99   Symbol* signature = method->signature();
 100   st.print("__");
 101   // find ')'
 102   int end;
 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 #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 }
 144 
 145 address NativeLookup::lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS) {
 146   address entry;
 147   // Compute complete JNI name for style
 148   stringStream st;
 149   if (os_style) os::print_jni_name_prefix_on(&st, args_size);
 150   st.print_raw(pure_name);
 151   st.print_raw(long_name);


< prev index next >