Mercurial > hg > truffle
comparison src/share/vm/prims/nativeLookup.cpp @ 2356:72dee110246f
6839872: remove implementation inheritance from JSR 292 APIs
Summary: consolidate runtime support in java.dyn.MethodHandleNatives; include transitional compatibility logic
Reviewed-by: twisti
author | jrose |
---|---|
date | Fri, 11 Mar 2011 22:33:47 -0800 |
parents | 3582bf76420e |
children | 8033953d67ff |
comparison
equal
deleted
inserted
replaced
2355:799d8ccf63cf | 2356:72dee110246f |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
105 void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls); | 105 void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls); |
106 void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls); | 106 void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls); |
107 void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass); | 107 void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass); |
108 } | 108 } |
109 | 109 |
110 #define CC (char*) /* cast a literal from (const char*) */ | |
111 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f) | |
112 | |
113 static JNINativeMethod lookup_special_native_methods[] = { | |
114 // Next two functions only exist for compatibility with 1.3.1 and earlier. | |
115 { CC"Java_java_io_ObjectOutputStream_getPrimitiveFieldValues", NULL, FN_PTR(JVM_GetPrimitiveFieldValues) }, // intercept ObjectOutputStream getPrimitiveFieldValues for faster serialization | |
116 { CC"Java_java_io_ObjectInputStream_setPrimitiveFieldValues", NULL, FN_PTR(JVM_SetPrimitiveFieldValues) }, // intercept ObjectInputStream setPrimitiveFieldValues for faster serialization | |
117 | |
118 { CC"Java_sun_misc_Unsafe_registerNatives", NULL, FN_PTR(JVM_RegisterUnsafeMethods) }, | |
119 { CC"Java_sun_dyn_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) }, // AllowTransitionalJSR292 | |
120 { CC"Java_java_dyn_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) }, // AllowTransitionalJSR292 | |
121 { CC"Java_sun_misc_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) } | |
122 }; | |
123 | |
110 static address lookup_special_native(char* jni_name) { | 124 static address lookup_special_native(char* jni_name) { |
111 // NB: To ignore the jni prefix and jni postfix strstr is used matching. | 125 int i = !JDK_Version::is_gte_jdk14x_version() ? 0 : 2; // see comment in lookup_special_native_methods |
112 if (!JDK_Version::is_gte_jdk14x_version()) { | 126 int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod); |
113 // These functions only exist for compatibility with 1.3.1 and earlier | 127 for (; i < count; i++) { |
114 // Intercept ObjectOutputStream getPrimitiveFieldValues for faster serialization | 128 // NB: To ignore the jni prefix and jni postfix strstr is used matching. |
115 if (strstr(jni_name, "Java_java_io_ObjectOutputStream_getPrimitiveFieldValues") != NULL) { | 129 if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) { |
116 return CAST_FROM_FN_PTR(address, JVM_GetPrimitiveFieldValues); | 130 return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr); |
117 } | 131 } |
118 // Intercept ObjectInputStream setPrimitiveFieldValues for faster serialization | 132 } |
119 if (strstr(jni_name, "Java_java_io_ObjectInputStream_setPrimitiveFieldValues") != NULL) { | |
120 return CAST_FROM_FN_PTR(address, JVM_SetPrimitiveFieldValues); | |
121 } | |
122 } | |
123 if (strstr(jni_name, "Java_sun_misc_Unsafe_registerNatives") != NULL) { | |
124 return CAST_FROM_FN_PTR(address, JVM_RegisterUnsafeMethods); | |
125 } | |
126 if (strstr(jni_name, "Java_sun_dyn_MethodHandleNatives_registerNatives") != NULL) { | |
127 return CAST_FROM_FN_PTR(address, JVM_RegisterMethodHandleMethods); | |
128 } | |
129 if (strstr(jni_name, "Java_sun_misc_Perf_registerNatives") != NULL) { | |
130 return CAST_FROM_FN_PTR(address, JVM_RegisterPerfMethods); | |
131 } | |
132 | |
133 return NULL; | 133 return NULL; |
134 } | 134 } |
135 | 135 |
136 address NativeLookup::lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS) { | 136 address NativeLookup::lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS) { |
137 address entry; | 137 address entry; |