hotspot/src/share/vm/prims/nativeLookup.cpp
changeset 20381 ed1047a3ac21
parent 17381 a53ac5bf4850
child 22838 82c7497fbad4
child 22234 da823d78ad65
equal deleted inserted replaced
20377:393ee12eccc8 20381:ed1047a3ac21
   127 
   127 
   128 #define CC (char*)  /* cast a literal from (const char*) */
   128 #define CC (char*)  /* cast a literal from (const char*) */
   129 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
   129 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
   130 
   130 
   131 static JNINativeMethod lookup_special_native_methods[] = {
   131 static JNINativeMethod lookup_special_native_methods[] = {
   132   // Next two functions only exist for compatibility with 1.3.1 and earlier.
       
   133   { CC"Java_java_io_ObjectOutputStream_getPrimitiveFieldValues",   NULL, FN_PTR(JVM_GetPrimitiveFieldValues)     },  // intercept ObjectOutputStream getPrimitiveFieldValues for faster serialization
       
   134   { CC"Java_java_io_ObjectInputStream_setPrimitiveFieldValues",    NULL, FN_PTR(JVM_SetPrimitiveFieldValues)     },  // intercept ObjectInputStream setPrimitiveFieldValues for faster serialization
       
   135 
       
   136   { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
   132   { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
   137   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
   133   { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
   138   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
   134   { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         },
   139   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
   135   { CC"Java_sun_hotspot_WhiteBox_registerNatives",                 NULL, FN_PTR(JVM_RegisterWhiteBoxMethods)     },
   140 };
   136 };
   141 
   137 
   142 static address lookup_special_native(char* jni_name) {
   138 static address lookup_special_native(char* jni_name) {
   143   int i = !JDK_Version::is_gte_jdk14x_version() ? 0 : 2;  // see comment in lookup_special_native_methods
       
   144   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
   139   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
   145   for (; i < count; i++) {
   140   for (int i = 0; i < count; i++) {
   146     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
   141     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
   147     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
   142     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
   148       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
   143       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
   149     }
   144     }
   150   }
   145   }