src/share/vm/prims/nativeLookup.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6839872 Sdiff src/share/vm/prims

src/share/vm/prims/nativeLookup.cpp

Print this page
rev 2143 : 6839872: remove implementation inheritance from JSR 292 APIs
Summary: Move all JSR 292 classes into the java.dyn package.
Reviewed-by:
   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  90 
  91 char* NativeLookup::long_jni_name(methodHandle method) {
  92   // Signature ignore the wrapping parenteses and the trailing return type
  93   stringStream st;
  94   Symbol* signature = method->signature();
  95   st.print("__");
  96   // find ')'
  97   int end;
  98   for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
  99   // skip first '('
 100   mangle_name_on(&st, signature, 1, end);
 101   return st.as_string();
 102 }
 103 
 104 extern "C" {
 105   void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls);
 106   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 107   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 108 }
 109 














 110 static address lookup_special_native(char* jni_name) {



 111   // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 112   if (!JDK_Version::is_gte_jdk14x_version()) {
 113     // These functions only exist for compatibility with 1.3.1 and earlier
 114     // Intercept ObjectOutputStream getPrimitiveFieldValues for faster serialization
 115     if (strstr(jni_name, "Java_java_io_ObjectOutputStream_getPrimitiveFieldValues") != NULL) {
 116       return CAST_FROM_FN_PTR(address, JVM_GetPrimitiveFieldValues);
 117     }
 118     // Intercept ObjectInputStream setPrimitiveFieldValues for faster serialization
 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;
 134 }
 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) {
 137   address entry;
 138   // Compute complete JNI name for style
 139   stringStream st;
 140   if (os_style) os::print_jni_name_prefix_on(&st, args_size);
 141   st.print_raw(pure_name);
 142   st.print_raw(long_name);
 143   if (os_style) os::print_jni_name_suffix_on(&st, args_size);
 144   char* jni_name = st.as_string();
 145 
 146   // If the loader is null we have a system class, so we attempt a lookup in
 147   // the native Java library. This takes care of any bootstrapping problems.
 148   // Note: It is critical for bootstrapping that Java_java_lang_ClassLoader_00024NativeLibrary_find
 149   // gets found the first time around - otherwise an infinite loop can occure. This is
 150   // another VM/library dependency
 151   Handle loader(THREAD,
 152                 instanceKlass::cast(method->method_holder())->class_loader());


   1 /*
   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.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  90 
  91 char* NativeLookup::long_jni_name(methodHandle method) {
  92   // Signature ignore the wrapping parenteses and the trailing return type
  93   stringStream st;
  94   Symbol* signature = method->signature();
  95   st.print("__");
  96   // find ')'
  97   int end;
  98   for (end = 0; end < signature->utf8_length() && signature->byte_at(end) != ')'; end++);
  99   // skip first '('
 100   mangle_name_on(&st, signature, 1, end);
 101   return st.as_string();
 102 }
 103 
 104 extern "C" {
 105   void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls);
 106   void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
 107   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 108 }
 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 
 124 static address lookup_special_native(char* jni_name) {
 125   int i = !JDK_Version::is_gte_jdk14x_version() ? 0 : 2;  // see comment in lookup_special_native_methods
 126   int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
 127   for (; i < count; i++) {
 128     // NB: To ignore the jni prefix and jni postfix strstr is used matching.
 129     if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
 130       return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);








 131     }


 132   }







 133   return NULL;
 134 }
 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) {
 137   address entry;
 138   // Compute complete JNI name for style
 139   stringStream st;
 140   if (os_style) os::print_jni_name_prefix_on(&st, args_size);
 141   st.print_raw(pure_name);
 142   st.print_raw(long_name);
 143   if (os_style) os::print_jni_name_suffix_on(&st, args_size);
 144   char* jni_name = st.as_string();
 145 
 146   // If the loader is null we have a system class, so we attempt a lookup in
 147   // the native Java library. This takes care of any bootstrapping problems.
 148   // Note: It is critical for bootstrapping that Java_java_lang_ClassLoader_00024NativeLibrary_find
 149   // gets found the first time around - otherwise an infinite loop can occure. This is
 150   // another VM/library dependency
 151   Handle loader(THREAD,
 152                 instanceKlass::cast(method->method_holder())->class_loader());


src/share/vm/prims/nativeLookup.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File