112 st.print("__");
113 // find ')'
114 int end;
115 for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
116 // skip first '('
117 mangle_name_on(&st, signature, 1, end);
118 return st.as_string();
119 }
120
121 extern "C" {
122 void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls);
123 void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
124 void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
125 void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
126 }
127
128 #define CC (char*) /* cast a literal from (const char*) */
129 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
130
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) },
137 { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
138 { CC"Java_sun_misc_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) },
139 { CC"Java_sun_hotspot_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) },
140 };
141
142 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);
145 for (; i < count; i++) {
146 // 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) {
148 return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
149 }
150 }
151 return NULL;
152 }
153
154 address NativeLookup::lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS) {
155 address entry;
156 // Compute complete JNI name for style
157 stringStream st;
158 if (os_style) os::print_jni_name_prefix_on(&st, args_size);
159 st.print_raw(pure_name);
160 st.print_raw(long_name);
161 if (os_style) os::print_jni_name_suffix_on(&st, args_size);
162 char* jni_name = st.as_string();
163
164 // If the loader is null we have a system class, so we attempt a lookup in
165 // the native Java library. This takes care of any bootstrapping problems.
|
112 st.print("__");
113 // find ')'
114 int end;
115 for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
116 // skip first '('
117 mangle_name_on(&st, signature, 1, end);
118 return st.as_string();
119 }
120
121 extern "C" {
122 void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls);
123 void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
124 void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
125 void JNICALL JVM_RegisterWhiteBoxMethods(JNIEnv *env, jclass wbclass);
126 }
127
128 #define CC (char*) /* cast a literal from (const char*) */
129 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
130
131 static JNINativeMethod lookup_special_native_methods[] = {
132 { CC"Java_sun_misc_Unsafe_registerNatives", NULL, FN_PTR(JVM_RegisterUnsafeMethods) },
133 { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
134 { CC"Java_sun_misc_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) },
135 { CC"Java_sun_hotspot_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) },
136 };
137
138 static address lookup_special_native(char* jni_name) {
139 int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
140 for (int i = 0; i < count; i++) {
141 // NB: To ignore the jni prefix and jni postfix strstr is used matching.
142 if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
143 return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
144 }
145 }
146 return NULL;
147 }
148
149 address NativeLookup::lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS) {
150 address entry;
151 // Compute complete JNI name for style
152 stringStream st;
153 if (os_style) os::print_jni_name_prefix_on(&st, args_size);
154 st.print_raw(pure_name);
155 st.print_raw(long_name);
156 if (os_style) os::print_jni_name_suffix_on(&st, args_size);
157 char* jni_name = st.as_string();
158
159 // If the loader is null we have a system class, so we attempt a lookup in
160 // the native Java library. This takes care of any bootstrapping problems.
|