< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page




1154 JNI_END
1155 
1156 
1157 static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str,
1158                                const char *sig, bool is_static, TRAPS) {
1159   // %%%% This code should probably just call into a method in the LinkResolver
1160   //
1161   // The class should have been loaded (we have an instance of the class
1162   // passed in) so the method and signature should already be in the symbol
1163   // table.  If they're not there, the method doesn't exist.
1164   const char *name_to_probe = (name_str == NULL)
1165                         ? vmSymbols::object_initializer_name()->as_C_string()
1166                         : name_str;
1167   TempNewSymbol name = SymbolTable::probe(name_to_probe, (int)strlen(name_to_probe));
1168   TempNewSymbol signature = SymbolTable::probe(sig, (int)strlen(sig));
1169 
1170   if (name == NULL || signature == NULL) {
1171     THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str);
1172   }
1173 
1174   Klass* klass = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz));

1175 
1176   // Throw a NoSuchMethodError exception if we have an instance of a
1177   // primitive java.lang.Class
1178   if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(clazz))) {
1179     ResourceMark rm;
1180     THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), err_msg("%s%s.%s%s", is_static ? "static " : "", klass->signature_name(), name_str, sig));
1181   }
1182 
1183   // Make sure class is linked and initialized before handing id's out to
1184   // Method*s.
1185   klass->initialize(CHECK_NULL);
1186 
1187   Method* m;
1188   if (name == vmSymbols::object_initializer_name() ||
1189       name == vmSymbols::class_initializer_name()) {
1190     // Never search superclasses for constructors
1191     if (klass->is_instance_klass()) {
1192       m = InstanceKlass::cast(klass)->find_method(name, signature);
1193     } else {
1194       m = NULL;
1195     }
1196   } else {
1197     m = klass->lookup_method(name, signature);
1198     if (m == NULL &&  klass->is_instance_klass()) {




1154 JNI_END
1155 
1156 
1157 static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str,
1158                                const char *sig, bool is_static, TRAPS) {
1159   // %%%% This code should probably just call into a method in the LinkResolver
1160   //
1161   // The class should have been loaded (we have an instance of the class
1162   // passed in) so the method and signature should already be in the symbol
1163   // table.  If they're not there, the method doesn't exist.
1164   const char *name_to_probe = (name_str == NULL)
1165                         ? vmSymbols::object_initializer_name()->as_C_string()
1166                         : name_str;
1167   TempNewSymbol name = SymbolTable::probe(name_to_probe, (int)strlen(name_to_probe));
1168   TempNewSymbol signature = SymbolTable::probe(sig, (int)strlen(sig));
1169 
1170   if (name == NULL || signature == NULL) {
1171     THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str);
1172   }
1173 
1174   oop mirror = JNIHandles::resolve_non_null(clazz);
1175   Klass* klass = java_lang_Class::as_Klass(mirror);
1176 
1177   // Throw a NoSuchMethodError exception if we have an instance of a
1178   // primitive java.lang.Class
1179   if (java_lang_Class::is_primitive(mirror)) {
1180     ResourceMark rm;
1181     THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), err_msg("%s%s.%s%s", is_static ? "static " : "", klass->signature_name(), name_str, sig));
1182   }
1183 
1184   // Make sure class is linked and initialized before handing id's out to
1185   // Method*s.
1186   klass->initialize(CHECK_NULL);
1187 
1188   Method* m;
1189   if (name == vmSymbols::object_initializer_name() ||
1190       name == vmSymbols::class_initializer_name()) {
1191     // Never search superclasses for constructors
1192     if (klass->is_instance_klass()) {
1193       m = InstanceKlass::cast(klass)->find_method(name, signature);
1194     } else {
1195       m = NULL;
1196     }
1197   } else {
1198     m = klass->lookup_method(name, signature);
1199     if (m == NULL &&  klass->is_instance_klass()) {


< prev index next >