Mercurial > hg > truffle
comparison src/share/vm/prims/jni.cpp @ 2177:3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
Summary: move symbols from permgen into C heap and reference count them
Reviewed-by: never, acorn, jmasa, stefank
author | coleenp |
---|---|
date | Thu, 27 Jan 2011 16:11:27 -0800 |
parents | 017cd8bce8a8 |
children | d25d4ca69222 c7f3d0b4570f |
comparison
equal
deleted
inserted
replaced
2176:27e4ea99855d | 2177:3582bf76420e |
---|---|
38 #include "oops/markOop.hpp" | 38 #include "oops/markOop.hpp" |
39 #include "oops/methodOop.hpp" | 39 #include "oops/methodOop.hpp" |
40 #include "oops/objArrayKlass.hpp" | 40 #include "oops/objArrayKlass.hpp" |
41 #include "oops/objArrayOop.hpp" | 41 #include "oops/objArrayOop.hpp" |
42 #include "oops/oop.inline.hpp" | 42 #include "oops/oop.inline.hpp" |
43 #include "oops/symbolOop.hpp" | 43 #include "oops/symbol.hpp" |
44 #include "oops/typeArrayKlass.hpp" | 44 #include "oops/typeArrayKlass.hpp" |
45 #include "oops/typeArrayOop.hpp" | 45 #include "oops/typeArrayOop.hpp" |
46 #include "prims/jni.h" | 46 #include "prims/jni.h" |
47 #include "prims/jniCheck.hpp" | 47 #include "prims/jniCheck.hpp" |
48 #include "prims/jniFastGetField.hpp" | 48 #include "prims/jniFastGetField.hpp" |
336 jclass cls = NULL; | 336 jclass cls = NULL; |
337 DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls); | 337 DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls); |
338 | 338 |
339 // Since exceptions can be thrown, class initialization can take place | 339 // Since exceptions can be thrown, class initialization can take place |
340 // if name is NULL no check for class name in .class stream has to be made. | 340 // if name is NULL no check for class name in .class stream has to be made. |
341 symbolHandle class_name; | |
342 if (name != NULL) { | 341 if (name != NULL) { |
343 const int str_len = (int)strlen(name); | 342 const int str_len = (int)strlen(name); |
344 if (str_len > symbolOopDesc::max_length()) { | 343 if (str_len > Symbol::max_length()) { |
345 // It's impossible to create this class; the name cannot fit | 344 // It's impossible to create this class; the name cannot fit |
346 // into the constant pool. | 345 // into the constant pool. |
347 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | 346 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
348 } | 347 } |
349 class_name = oopFactory::new_symbol_handle(name, str_len, CHECK_NULL); | 348 } |
350 } | 349 TempNewSymbol class_name = SymbolTable::new_symbol(name, THREAD); |
351 | 350 |
352 ResourceMark rm(THREAD); | 351 ResourceMark rm(THREAD); |
353 ClassFileStream st((u1*) buf, bufLen, NULL); | 352 ClassFileStream st((u1*) buf, bufLen, NULL); |
354 Handle class_loader (THREAD, JNIHandles::resolve(loaderRef)); | 353 Handle class_loader (THREAD, JNIHandles::resolve(loaderRef)); |
355 | 354 |
392 bool first_time = first_time_FindClass; | 391 bool first_time = first_time_FindClass; |
393 first_time_FindClass = false; | 392 first_time_FindClass = false; |
394 | 393 |
395 // Sanity check the name: it cannot be null or larger than the maximum size | 394 // Sanity check the name: it cannot be null or larger than the maximum size |
396 // name we can fit in the constant pool. | 395 // name we can fit in the constant pool. |
397 if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) { | 396 if (name == NULL || (int)strlen(name) > Symbol::max_length()) { |
398 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | 397 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
399 } | 398 } |
400 | 399 |
401 //%note jni_3 | 400 //%note jni_3 |
402 Handle loader; | 401 Handle loader; |
409 // in the correct class context. | 408 // in the correct class context. |
410 if (loader.is_null() && | 409 if (loader.is_null() && |
411 k->name() == vmSymbols::java_lang_ClassLoader_NativeLibrary()) { | 410 k->name() == vmSymbols::java_lang_ClassLoader_NativeLibrary()) { |
412 JavaValue result(T_OBJECT); | 411 JavaValue result(T_OBJECT); |
413 JavaCalls::call_static(&result, k, | 412 JavaCalls::call_static(&result, k, |
414 vmSymbolHandles::getFromClass_name(), | 413 vmSymbols::getFromClass_name(), |
415 vmSymbolHandles::void_class_signature(), | 414 vmSymbols::void_class_signature(), |
416 thread); | 415 thread); |
417 if (HAS_PENDING_EXCEPTION) { | 416 if (HAS_PENDING_EXCEPTION) { |
418 Handle ex(thread, thread->pending_exception()); | 417 Handle ex(thread, thread->pending_exception()); |
419 CLEAR_PENDING_EXCEPTION; | 418 CLEAR_PENDING_EXCEPTION; |
420 THROW_HANDLE_0(ex); | 419 THROW_HANDLE_0(ex); |
428 } else { | 427 } else { |
429 // We call ClassLoader.getSystemClassLoader to obtain the system class loader. | 428 // We call ClassLoader.getSystemClassLoader to obtain the system class loader. |
430 loader = Handle(THREAD, SystemDictionary::java_system_loader()); | 429 loader = Handle(THREAD, SystemDictionary::java_system_loader()); |
431 } | 430 } |
432 | 431 |
433 symbolHandle sym = oopFactory::new_symbol_handle(name, CHECK_NULL); | 432 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); |
434 result = find_class_from_class_loader(env, sym, true, loader, | 433 result = find_class_from_class_loader(env, sym, true, loader, |
435 protection_domain, true, thread); | 434 protection_domain, true, thread); |
436 | 435 |
437 if (TraceClassResolution && result != NULL) { | 436 if (TraceClassResolution && result != NULL) { |
438 trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); | 437 trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); |
607 DTRACE_PROBE3(hotspot_jni, ThrowNew__entry, env, clazz, message); | 606 DTRACE_PROBE3(hotspot_jni, ThrowNew__entry, env, clazz, message); |
608 jint ret = JNI_OK; | 607 jint ret = JNI_OK; |
609 DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret); | 608 DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret); |
610 | 609 |
611 instanceKlass* k = instanceKlass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | 610 instanceKlass* k = instanceKlass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); |
612 symbolHandle name = symbolHandle(THREAD, k->name()); | 611 Symbol* name = k->name(); |
613 Handle class_loader (THREAD, k->class_loader()); | 612 Handle class_loader (THREAD, k->class_loader()); |
614 Handle protection_domain (THREAD, k->protection_domain()); | 613 Handle protection_domain (THREAD, k->protection_domain()); |
615 THROW_MSG_LOADER_(name, (char *)message, class_loader, protection_domain, JNI_OK); | 614 THROW_MSG_LOADER_(name, (char *)message, class_loader, protection_domain, JNI_OK); |
616 ShouldNotReachHere(); | 615 ShouldNotReachHere(); |
617 JNI_END | 616 JNI_END |
661 JavaValue result(T_VOID); | 660 JavaValue result(T_VOID); |
662 JavaCalls::call_virtual(&result, | 661 JavaCalls::call_virtual(&result, |
663 ex, | 662 ex, |
664 KlassHandle(THREAD, | 663 KlassHandle(THREAD, |
665 SystemDictionary::Throwable_klass()), | 664 SystemDictionary::Throwable_klass()), |
666 vmSymbolHandles::printStackTrace_name(), | 665 vmSymbols::printStackTrace_name(), |
667 vmSymbolHandles::void_method_signature(), | 666 vmSymbols::void_method_signature(), |
668 THREAD); | 667 THREAD); |
669 // If an exception is thrown in the call it gets thrown away. Not much | 668 // If an exception is thrown in the call it gets thrown away. Not much |
670 // we can do with it. The native code that calls this, does not check | 669 // we can do with it. The native code that calls this, does not check |
671 // for the exception - hence, it might still be in the thread when DestroyVM gets | 670 // for the exception - hence, it might still be in the thread when DestroyVM gets |
672 // called, potentially causing a few asserts to trigger - since no pending exception | 671 // called, potentially causing a few asserts to trigger - since no pending exception |
836 virtual void get_long () = 0; | 835 virtual void get_long () = 0; |
837 virtual void get_float () = 0; | 836 virtual void get_float () = 0; |
838 virtual void get_double () = 0; | 837 virtual void get_double () = 0; |
839 virtual void get_object () = 0; | 838 virtual void get_object () = 0; |
840 | 839 |
841 JNI_ArgumentPusher(Thread *thread, symbolOop signature) | 840 JNI_ArgumentPusher(Symbol* signature) : SignatureIterator(signature) { |
842 : SignatureIterator(thread, signature) { | |
843 this->_return_type = T_ILLEGAL; | 841 this->_return_type = T_ILLEGAL; |
844 _arguments = NULL; | 842 _arguments = NULL; |
845 } | 843 } |
846 | 844 |
847 public: | 845 public: |
893 _ap = rap; | 891 _ap = rap; |
894 #endif | 892 #endif |
895 } | 893 } |
896 | 894 |
897 public: | 895 public: |
898 JNI_ArgumentPusherVaArg(Thread *thread, symbolOop signature, va_list rap) | 896 JNI_ArgumentPusherVaArg(Symbol* signature, va_list rap) |
899 : JNI_ArgumentPusher(thread, signature) { | 897 : JNI_ArgumentPusher(signature) { |
900 set_ap(rap); | 898 set_ap(rap); |
901 } | 899 } |
902 JNI_ArgumentPusherVaArg(Thread *thread, jmethodID method_id, va_list rap) | 900 JNI_ArgumentPusherVaArg(jmethodID method_id, va_list rap) |
903 : JNI_ArgumentPusher(thread, JNIHandles::resolve_jmethod_id(method_id)->signature()) { | 901 : JNI_ArgumentPusher(JNIHandles::resolve_jmethod_id(method_id)->signature()) { |
904 set_ap(rap); | 902 set_ap(rap); |
905 } | 903 } |
906 | 904 |
907 // Optimized path if we have the bitvector form of signature | 905 // Optimized path if we have the bitvector form of signature |
908 void iterate( uint64_t fingerprint ) { | 906 void iterate( uint64_t fingerprint ) { |
964 inline void get_object() { _arguments->push_oop(Handle((oop *)(_ap++)->l, false)); } | 962 inline void get_object() { _arguments->push_oop(Handle((oop *)(_ap++)->l, false)); } |
965 | 963 |
966 inline void set_ap(const jvalue *rap) { _ap = rap; } | 964 inline void set_ap(const jvalue *rap) { _ap = rap; } |
967 | 965 |
968 public: | 966 public: |
969 JNI_ArgumentPusherArray(Thread *thread, symbolOop signature, const jvalue *rap) | 967 JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap) |
970 : JNI_ArgumentPusher(thread, signature) { | 968 : JNI_ArgumentPusher(signature) { |
971 set_ap(rap); | 969 set_ap(rap); |
972 } | 970 } |
973 JNI_ArgumentPusherArray(Thread *thread, jmethodID method_id, const jvalue *rap) | 971 JNI_ArgumentPusherArray(jmethodID method_id, const jvalue *rap) |
974 : JNI_ArgumentPusher(thread, JNIHandles::resolve_jmethod_id(method_id)->signature()) { | 972 : JNI_ArgumentPusher(JNIHandles::resolve_jmethod_id(method_id)->signature()) { |
975 set_ap(rap); | 973 set_ap(rap); |
976 } | 974 } |
977 | 975 |
978 // Optimized path if we have the bitvector form of signature | 976 // Optimized path if we have the bitvector form of signature |
979 void iterate( uint64_t fingerprint ) { | 977 void iterate( uint64_t fingerprint ) { |
1036 assert(!method.is_null() , "method should not be null"); | 1034 assert(!method.is_null() , "method should not be null"); |
1037 | 1035 |
1038 KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc) | 1036 KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc) |
1039 if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass()); | 1037 if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass()); |
1040 KlassHandle spec_klass (THREAD, method->method_holder()); | 1038 KlassHandle spec_klass (THREAD, method->method_holder()); |
1041 symbolHandle name (THREAD, method->name()); | 1039 Symbol* name = method->name(); |
1042 symbolHandle signature (THREAD, method->signature()); | 1040 Symbol* signature = method->signature(); |
1043 CallInfo info; | 1041 CallInfo info; |
1044 LinkResolver::resolve_interface_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); | 1042 LinkResolver::resolve_interface_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); |
1045 return info.selected_method(); | 1043 return info.selected_method(); |
1046 } | 1044 } |
1047 | 1045 |
1049 assert(!method.is_null() , "method should not be null"); | 1047 assert(!method.is_null() , "method should not be null"); |
1050 | 1048 |
1051 KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc) | 1049 KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc) |
1052 if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass()); | 1050 if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass()); |
1053 KlassHandle spec_klass (THREAD, method->method_holder()); | 1051 KlassHandle spec_klass (THREAD, method->method_holder()); |
1054 symbolHandle name (THREAD, method->name()); | 1052 Symbol* name = method->name(); |
1055 symbolHandle signature (THREAD, method->signature()); | 1053 Symbol* signature = method->signature(); |
1056 CallInfo info; | 1054 CallInfo info; |
1057 LinkResolver::resolve_virtual_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); | 1055 LinkResolver::resolve_virtual_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); |
1058 return info.selected_method(); | 1056 return info.selected_method(); |
1059 } | 1057 } |
1060 | 1058 |
1071 args->set_java_argument_object(&java_args); | 1069 args->set_java_argument_object(&java_args); |
1072 | 1070 |
1073 assert(method->is_static(), "method should be static"); | 1071 assert(method->is_static(), "method should be static"); |
1074 | 1072 |
1075 // Fill out JavaCallArguments object | 1073 // Fill out JavaCallArguments object |
1076 args->iterate( Fingerprinter(THREAD, method).fingerprint() ); | 1074 args->iterate( Fingerprinter(method).fingerprint() ); |
1077 // Initialize result type | 1075 // Initialize result type |
1078 result->set_type(args->get_ret_type()); | 1076 result->set_type(args->get_ret_type()); |
1079 | 1077 |
1080 // Invoke the method. Result is returned as oop. | 1078 // Invoke the method. Result is returned as oop. |
1081 JavaCalls::call(result, method, &java_args, CHECK); | 1079 JavaCalls::call(result, method, &java_args, CHECK); |
1147 // handle arguments | 1145 // handle arguments |
1148 assert(!method->is_static(), "method should not be static"); | 1146 assert(!method->is_static(), "method should not be static"); |
1149 args->push_receiver(h_recv); // Push jobject handle | 1147 args->push_receiver(h_recv); // Push jobject handle |
1150 | 1148 |
1151 // Fill out JavaCallArguments object | 1149 // Fill out JavaCallArguments object |
1152 args->iterate( Fingerprinter(THREAD, method).fingerprint() ); | 1150 args->iterate( Fingerprinter(method).fingerprint() ); |
1153 // Initialize result type | 1151 // Initialize result type |
1154 result->set_type(args->get_ret_type()); | 1152 result->set_type(args->get_ret_type()); |
1155 | 1153 |
1156 // Invoke the method. Result is returned as oop. | 1154 // Invoke the method. Result is returned as oop. |
1157 JavaCalls::call(result, method, &java_args, CHECK); | 1155 JavaCalls::call(result, method, &java_args, CHECK); |
1194 DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj); | 1192 DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj); |
1195 | 1193 |
1196 instanceOop i = alloc_object(clazz, CHECK_NULL); | 1194 instanceOop i = alloc_object(clazz, CHECK_NULL); |
1197 obj = JNIHandles::make_local(env, i); | 1195 obj = JNIHandles::make_local(env, i); |
1198 JavaValue jvalue(T_VOID); | 1196 JavaValue jvalue(T_VOID); |
1199 JNI_ArgumentPusherArray ap(THREAD, methodID, args); | 1197 JNI_ArgumentPusherArray ap(methodID, args); |
1200 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); | 1198 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1201 return obj; | 1199 return obj; |
1202 JNI_END | 1200 JNI_END |
1203 | 1201 |
1204 DT_RETURN_MARK_DECL(NewObjectV, jobject); | 1202 DT_RETURN_MARK_DECL(NewObjectV, jobject); |
1210 DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj); | 1208 DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj); |
1211 | 1209 |
1212 instanceOop i = alloc_object(clazz, CHECK_NULL); | 1210 instanceOop i = alloc_object(clazz, CHECK_NULL); |
1213 obj = JNIHandles::make_local(env, i); | 1211 obj = JNIHandles::make_local(env, i); |
1214 JavaValue jvalue(T_VOID); | 1212 JavaValue jvalue(T_VOID); |
1215 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); | 1213 JNI_ArgumentPusherVaArg ap(methodID, args); |
1216 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); | 1214 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1217 return obj; | 1215 return obj; |
1218 JNI_END | 1216 JNI_END |
1219 | 1217 |
1220 DT_RETURN_MARK_DECL(NewObject, jobject); | 1218 DT_RETURN_MARK_DECL(NewObject, jobject); |
1228 instanceOop i = alloc_object(clazz, CHECK_NULL); | 1226 instanceOop i = alloc_object(clazz, CHECK_NULL); |
1229 obj = JNIHandles::make_local(env, i); | 1227 obj = JNIHandles::make_local(env, i); |
1230 va_list args; | 1228 va_list args; |
1231 va_start(args, methodID); | 1229 va_start(args, methodID); |
1232 JavaValue jvalue(T_VOID); | 1230 JavaValue jvalue(T_VOID); |
1233 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); | 1231 JNI_ArgumentPusherVaArg ap(methodID, args); |
1234 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); | 1232 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL); |
1235 va_end(args); | 1233 va_end(args); |
1236 return obj; | 1234 return obj; |
1237 JNI_END | 1235 JNI_END |
1238 | 1236 |
1269 // %%%% This code should probably just call into a method in the LinkResolver | 1267 // %%%% This code should probably just call into a method in the LinkResolver |
1270 // | 1268 // |
1271 // The class should have been loaded (we have an instance of the class | 1269 // The class should have been loaded (we have an instance of the class |
1272 // passed in) so the method and signature should already be in the symbol | 1270 // passed in) so the method and signature should already be in the symbol |
1273 // table. If they're not there, the method doesn't exist. | 1271 // table. If they're not there, the method doesn't exist. |
1274 symbolHandle signature = | 1272 const char *name_to_probe = (name_str == NULL) |
1275 symbolHandle(THREAD, SymbolTable::probe(sig, (int)strlen(sig))); | 1273 ? vmSymbols::object_initializer_name()->as_C_string() |
1276 symbolHandle name; | 1274 : name_str; |
1277 if (name_str == NULL) { | 1275 TempNewSymbol name = SymbolTable::probe(name_to_probe, (int)strlen(name_to_probe)); |
1278 name = vmSymbolHandles::object_initializer_name(); | 1276 TempNewSymbol signature = SymbolTable::probe(sig, (int)strlen(sig)); |
1279 } else { | 1277 |
1280 name = symbolHandle(THREAD, | 1278 if (name == NULL || signature == NULL) { |
1281 SymbolTable::probe(name_str, (int)strlen(name_str))); | |
1282 } | |
1283 if (name.is_null() || signature.is_null()) { | |
1284 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | 1279 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); |
1285 } | 1280 } |
1286 | 1281 |
1287 // Throw a NoSuchMethodError exception if we have an instance of a | 1282 // Throw a NoSuchMethodError exception if we have an instance of a |
1288 // primitive java.lang.Class | 1283 // primitive java.lang.Class |
1296 // Make sure class is linked and initialized before handing id's out to | 1291 // Make sure class is linked and initialized before handing id's out to |
1297 // methodOops. | 1292 // methodOops. |
1298 Klass::cast(klass())->initialize(CHECK_NULL); | 1293 Klass::cast(klass())->initialize(CHECK_NULL); |
1299 | 1294 |
1300 methodOop m; | 1295 methodOop m; |
1301 if (name() == vmSymbols::object_initializer_name() || | 1296 if (name == vmSymbols::object_initializer_name() || |
1302 name() == vmSymbols::class_initializer_name()) { | 1297 name == vmSymbols::class_initializer_name()) { |
1303 // Never search superclasses for constructors | 1298 // Never search superclasses for constructors |
1304 if (klass->oop_is_instance()) { | 1299 if (klass->oop_is_instance()) { |
1305 m = instanceKlass::cast(klass())->find_method(name(), signature()); | 1300 m = instanceKlass::cast(klass())->find_method(name, signature); |
1306 } else { | 1301 } else { |
1307 m = NULL; | 1302 m = NULL; |
1308 } | 1303 } |
1309 } else { | 1304 } else { |
1310 m = klass->lookup_method(name(), signature()); | 1305 m = klass->lookup_method(name, signature); |
1311 // Look up interfaces | 1306 // Look up interfaces |
1312 if (m == NULL && klass->oop_is_instance()) { | 1307 if (m == NULL && klass->oop_is_instance()) { |
1313 m = instanceKlass::cast(klass())->lookup_method_in_all_interfaces(name(), | 1308 m = instanceKlass::cast(klass())->lookup_method_in_all_interfaces(name, |
1314 signature()); | 1309 signature); |
1315 } | 1310 } |
1316 } | 1311 } |
1317 if (m == NULL || (m->is_static() != is_static)) { | 1312 if (m == NULL || (m->is_static() != is_static)) { |
1318 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); | 1313 THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str); |
1319 } | 1314 } |
1363 (const ResultType&)ret);\ | 1358 (const ResultType&)ret);\ |
1364 \ | 1359 \ |
1365 va_list args; \ | 1360 va_list args; \ |
1366 va_start(args, methodID); \ | 1361 va_start(args, methodID); \ |
1367 JavaValue jvalue(Tag); \ | 1362 JavaValue jvalue(Tag); \ |
1368 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \ | 1363 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
1369 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ | 1364 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1370 va_end(args); \ | 1365 va_end(args); \ |
1371 ret = jvalue.get_##ResultType(); \ | 1366 ret = jvalue.get_##ResultType(); \ |
1372 return ret;\ | 1367 return ret;\ |
1373 JNI_END \ | 1368 JNI_END \ |
1381 ResultType ret = 0;\ | 1376 ResultType ret = 0;\ |
1382 DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ | 1377 DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ |
1383 (const ResultType&)ret);\ | 1378 (const ResultType&)ret);\ |
1384 \ | 1379 \ |
1385 JavaValue jvalue(Tag); \ | 1380 JavaValue jvalue(Tag); \ |
1386 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \ | 1381 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
1387 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ | 1382 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1388 ret = jvalue.get_##ResultType(); \ | 1383 ret = jvalue.get_##ResultType(); \ |
1389 return ret;\ | 1384 return ret;\ |
1390 JNI_END \ | 1385 JNI_END \ |
1391 \ | 1386 \ |
1397 ResultType ret = 0;\ | 1392 ResultType ret = 0;\ |
1398 DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ | 1393 DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ |
1399 (const ResultType&)ret);\ | 1394 (const ResultType&)ret);\ |
1400 \ | 1395 \ |
1401 JavaValue jvalue(Tag); \ | 1396 JavaValue jvalue(Tag); \ |
1402 JNI_ArgumentPusherArray ap(THREAD, methodID, args); \ | 1397 JNI_ArgumentPusherArray ap(methodID, args); \ |
1403 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ | 1398 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ |
1404 ret = jvalue.get_##ResultType(); \ | 1399 ret = jvalue.get_##ResultType(); \ |
1405 return ret;\ | 1400 return ret;\ |
1406 JNI_END | 1401 JNI_END |
1407 | 1402 |
1427 DT_VOID_RETURN_MARK(CallVoidMethod); | 1422 DT_VOID_RETURN_MARK(CallVoidMethod); |
1428 | 1423 |
1429 va_list args; | 1424 va_list args; |
1430 va_start(args, methodID); | 1425 va_start(args, methodID); |
1431 JavaValue jvalue(T_VOID); | 1426 JavaValue jvalue(T_VOID); |
1432 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); | 1427 JNI_ArgumentPusherVaArg ap(methodID, args); |
1433 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); | 1428 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1434 va_end(args); | 1429 va_end(args); |
1435 JNI_END | 1430 JNI_END |
1436 | 1431 |
1437 | 1432 |
1439 JNIWrapper("CallVoidMethodV"); | 1434 JNIWrapper("CallVoidMethodV"); |
1440 DTRACE_PROBE3(hotspot_jni, CallVoidMethodV__entry, env, obj, methodID); | 1435 DTRACE_PROBE3(hotspot_jni, CallVoidMethodV__entry, env, obj, methodID); |
1441 DT_VOID_RETURN_MARK(CallVoidMethodV); | 1436 DT_VOID_RETURN_MARK(CallVoidMethodV); |
1442 | 1437 |
1443 JavaValue jvalue(T_VOID); | 1438 JavaValue jvalue(T_VOID); |
1444 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); | 1439 JNI_ArgumentPusherVaArg ap(methodID, args); |
1445 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); | 1440 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1446 JNI_END | 1441 JNI_END |
1447 | 1442 |
1448 | 1443 |
1449 JNI_ENTRY(void, jni_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) | 1444 JNI_ENTRY(void, jni_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) |
1450 JNIWrapper("CallVoidMethodA"); | 1445 JNIWrapper("CallVoidMethodA"); |
1451 DTRACE_PROBE3(hotspot_jni, CallVoidMethodA__entry, env, obj, methodID); | 1446 DTRACE_PROBE3(hotspot_jni, CallVoidMethodA__entry, env, obj, methodID); |
1452 DT_VOID_RETURN_MARK(CallVoidMethodA); | 1447 DT_VOID_RETURN_MARK(CallVoidMethodA); |
1453 | 1448 |
1454 JavaValue jvalue(T_VOID); | 1449 JavaValue jvalue(T_VOID); |
1455 JNI_ArgumentPusherArray ap(THREAD, methodID, args); | 1450 JNI_ArgumentPusherArray ap(methodID, args); |
1456 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); | 1451 jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK); |
1457 JNI_END | 1452 JNI_END |
1458 | 1453 |
1459 | 1454 |
1460 #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag) \ | 1455 #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag) \ |
1473 (const ResultType&)ret);\ | 1468 (const ResultType&)ret);\ |
1474 \ | 1469 \ |
1475 va_list args; \ | 1470 va_list args; \ |
1476 va_start(args, methodID); \ | 1471 va_start(args, methodID); \ |
1477 JavaValue jvalue(Tag); \ | 1472 JavaValue jvalue(Tag); \ |
1478 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \ | 1473 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
1479 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ | 1474 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
1480 va_end(args); \ | 1475 va_end(args); \ |
1481 ret = jvalue.get_##ResultType(); \ | 1476 ret = jvalue.get_##ResultType(); \ |
1482 return ret;\ | 1477 return ret;\ |
1483 JNI_END \ | 1478 JNI_END \ |
1489 ResultType ret;\ | 1484 ResultType ret;\ |
1490 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \ | 1485 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \ |
1491 (const ResultType&)ret);\ | 1486 (const ResultType&)ret);\ |
1492 \ | 1487 \ |
1493 JavaValue jvalue(Tag); \ | 1488 JavaValue jvalue(Tag); \ |
1494 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \ | 1489 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
1495 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ | 1490 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
1496 ret = jvalue.get_##ResultType(); \ | 1491 ret = jvalue.get_##ResultType(); \ |
1497 return ret;\ | 1492 return ret;\ |
1498 JNI_END \ | 1493 JNI_END \ |
1499 \ | 1494 \ |
1504 ResultType ret;\ | 1499 ResultType ret;\ |
1505 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \ | 1500 DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \ |
1506 (const ResultType&)ret);\ | 1501 (const ResultType&)ret);\ |
1507 \ | 1502 \ |
1508 JavaValue jvalue(Tag); \ | 1503 JavaValue jvalue(Tag); \ |
1509 JNI_ArgumentPusherArray ap(THREAD, methodID, args); \ | 1504 JNI_ArgumentPusherArray ap(methodID, args); \ |
1510 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ | 1505 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ |
1511 ret = jvalue.get_##ResultType(); \ | 1506 ret = jvalue.get_##ResultType(); \ |
1512 return ret;\ | 1507 return ret;\ |
1513 JNI_END | 1508 JNI_END |
1514 | 1509 |
1537 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethod); | 1532 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethod); |
1538 | 1533 |
1539 va_list args; | 1534 va_list args; |
1540 va_start(args, methodID); | 1535 va_start(args, methodID); |
1541 JavaValue jvalue(T_VOID); | 1536 JavaValue jvalue(T_VOID); |
1542 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); | 1537 JNI_ArgumentPusherVaArg ap(methodID, args); |
1543 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); | 1538 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
1544 va_end(args); | 1539 va_end(args); |
1545 JNI_END | 1540 JNI_END |
1546 | 1541 |
1547 | 1542 |
1551 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodV__entry, | 1546 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodV__entry, |
1552 env, obj, cls, methodID); | 1547 env, obj, cls, methodID); |
1553 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodV); | 1548 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodV); |
1554 | 1549 |
1555 JavaValue jvalue(T_VOID); | 1550 JavaValue jvalue(T_VOID); |
1556 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); | 1551 JNI_ArgumentPusherVaArg ap(methodID, args); |
1557 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); | 1552 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
1558 JNI_END | 1553 JNI_END |
1559 | 1554 |
1560 | 1555 |
1561 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) | 1556 JNI_ENTRY(void, jni_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) |
1562 JNIWrapper("CallNonvirtualVoidMethodA"); | 1557 JNIWrapper("CallNonvirtualVoidMethodA"); |
1563 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodA__entry, | 1558 DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodA__entry, |
1564 env, obj, cls, methodID); | 1559 env, obj, cls, methodID); |
1565 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodA); | 1560 DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodA); |
1566 JavaValue jvalue(T_VOID); | 1561 JavaValue jvalue(T_VOID); |
1567 JNI_ArgumentPusherArray ap(THREAD, methodID, args); | 1562 JNI_ArgumentPusherArray ap(methodID, args); |
1568 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); | 1563 jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK); |
1569 JNI_END | 1564 JNI_END |
1570 | 1565 |
1571 | 1566 |
1572 #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag) \ | 1567 #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag) \ |
1585 (const ResultType&)ret);\ | 1580 (const ResultType&)ret);\ |
1586 \ | 1581 \ |
1587 va_list args; \ | 1582 va_list args; \ |
1588 va_start(args, methodID); \ | 1583 va_start(args, methodID); \ |
1589 JavaValue jvalue(Tag); \ | 1584 JavaValue jvalue(Tag); \ |
1590 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \ | 1585 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
1591 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ | 1586 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
1592 va_end(args); \ | 1587 va_end(args); \ |
1593 ret = jvalue.get_##ResultType(); \ | 1588 ret = jvalue.get_##ResultType(); \ |
1594 return ret;\ | 1589 return ret;\ |
1595 JNI_END \ | 1590 JNI_END \ |
1601 ResultType ret = 0;\ | 1596 ResultType ret = 0;\ |
1602 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \ | 1597 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \ |
1603 (const ResultType&)ret);\ | 1598 (const ResultType&)ret);\ |
1604 \ | 1599 \ |
1605 JavaValue jvalue(Tag); \ | 1600 JavaValue jvalue(Tag); \ |
1606 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \ | 1601 JNI_ArgumentPusherVaArg ap(methodID, args); \ |
1607 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ | 1602 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
1608 ret = jvalue.get_##ResultType(); \ | 1603 ret = jvalue.get_##ResultType(); \ |
1609 return ret;\ | 1604 return ret;\ |
1610 JNI_END \ | 1605 JNI_END \ |
1611 \ | 1606 \ |
1616 ResultType ret = 0;\ | 1611 ResultType ret = 0;\ |
1617 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \ | 1612 DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \ |
1618 (const ResultType&)ret);\ | 1613 (const ResultType&)ret);\ |
1619 \ | 1614 \ |
1620 JavaValue jvalue(Tag); \ | 1615 JavaValue jvalue(Tag); \ |
1621 JNI_ArgumentPusherArray ap(THREAD, methodID, args); \ | 1616 JNI_ArgumentPusherArray ap(methodID, args); \ |
1622 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ | 1617 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ |
1623 ret = jvalue.get_##ResultType(); \ | 1618 ret = jvalue.get_##ResultType(); \ |
1624 return ret;\ | 1619 return ret;\ |
1625 JNI_END | 1620 JNI_END |
1626 | 1621 |
1647 DT_VOID_RETURN_MARK(CallStaticVoidMethod); | 1642 DT_VOID_RETURN_MARK(CallStaticVoidMethod); |
1648 | 1643 |
1649 va_list args; | 1644 va_list args; |
1650 va_start(args, methodID); | 1645 va_start(args, methodID); |
1651 JavaValue jvalue(T_VOID); | 1646 JavaValue jvalue(T_VOID); |
1652 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); | 1647 JNI_ArgumentPusherVaArg ap(methodID, args); |
1653 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); | 1648 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
1654 va_end(args); | 1649 va_end(args); |
1655 JNI_END | 1650 JNI_END |
1656 | 1651 |
1657 | 1652 |
1659 JNIWrapper("CallStaticVoidMethodV"); | 1654 JNIWrapper("CallStaticVoidMethodV"); |
1660 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodV__entry, env, cls, methodID); | 1655 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodV__entry, env, cls, methodID); |
1661 DT_VOID_RETURN_MARK(CallStaticVoidMethodV); | 1656 DT_VOID_RETURN_MARK(CallStaticVoidMethodV); |
1662 | 1657 |
1663 JavaValue jvalue(T_VOID); | 1658 JavaValue jvalue(T_VOID); |
1664 JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); | 1659 JNI_ArgumentPusherVaArg ap(methodID, args); |
1665 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); | 1660 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
1666 JNI_END | 1661 JNI_END |
1667 | 1662 |
1668 | 1663 |
1669 JNI_ENTRY(void, jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) | 1664 JNI_ENTRY(void, jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) |
1670 JNIWrapper("CallStaticVoidMethodA"); | 1665 JNIWrapper("CallStaticVoidMethodA"); |
1671 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodA__entry, env, cls, methodID); | 1666 DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodA__entry, env, cls, methodID); |
1672 DT_VOID_RETURN_MARK(CallStaticVoidMethodA); | 1667 DT_VOID_RETURN_MARK(CallStaticVoidMethodA); |
1673 | 1668 |
1674 JavaValue jvalue(T_VOID); | 1669 JavaValue jvalue(T_VOID); |
1675 JNI_ArgumentPusherArray ap(THREAD, methodID, args); | 1670 JNI_ArgumentPusherArray ap(methodID, args); |
1676 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); | 1671 jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK); |
1677 JNI_END | 1672 JNI_END |
1678 | 1673 |
1679 | 1674 |
1680 // | 1675 // |
1692 DT_RETURN_MARK(GetFieldID, jfieldID, (const jfieldID&)ret); | 1687 DT_RETURN_MARK(GetFieldID, jfieldID, (const jfieldID&)ret); |
1693 | 1688 |
1694 // The class should have been loaded (we have an instance of the class | 1689 // The class should have been loaded (we have an instance of the class |
1695 // passed in) so the field and signature should already be in the symbol | 1690 // passed in) so the field and signature should already be in the symbol |
1696 // table. If they're not there, the field doesn't exist. | 1691 // table. If they're not there, the field doesn't exist. |
1697 symbolHandle fieldname = | 1692 TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); |
1698 symbolHandle(THREAD, SymbolTable::probe(name, (int)strlen(name))); | 1693 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
1699 symbolHandle signame = | 1694 if (fieldname == NULL || signame == NULL) { |
1700 symbolHandle(THREAD, SymbolTable::probe(sig, (int)strlen(sig))); | |
1701 if (fieldname.is_null() || signame.is_null()) { | |
1702 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); | 1695 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
1703 } | 1696 } |
1704 KlassHandle k(THREAD, | 1697 KlassHandle k(THREAD, |
1705 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | 1698 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); |
1706 // Make sure class is initialized before handing id's out to fields | 1699 // Make sure class is initialized before handing id's out to fields |
1707 Klass::cast(k())->initialize(CHECK_NULL); | 1700 Klass::cast(k())->initialize(CHECK_NULL); |
1708 | 1701 |
1709 fieldDescriptor fd; | 1702 fieldDescriptor fd; |
1710 if (!Klass::cast(k())->oop_is_instance() || | 1703 if (!Klass::cast(k())->oop_is_instance() || |
1711 !instanceKlass::cast(k())->find_field(fieldname(), signame(), false, &fd)) { | 1704 !instanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) { |
1712 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); | 1705 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
1713 } | 1706 } |
1714 | 1707 |
1715 // A jfieldID for a non-static field is simply the offset of the field within the instanceOop | 1708 // A jfieldID for a non-static field is simply the offset of the field within the instanceOop |
1716 // It may also have hash bits for k, if VerifyJNIFields is turned on. | 1709 // It may also have hash bits for k, if VerifyJNIFields is turned on. |
1891 DT_RETURN_MARK(GetStaticFieldID, jfieldID, (const jfieldID&)ret); | 1884 DT_RETURN_MARK(GetStaticFieldID, jfieldID, (const jfieldID&)ret); |
1892 | 1885 |
1893 // The class should have been loaded (we have an instance of the class | 1886 // The class should have been loaded (we have an instance of the class |
1894 // passed in) so the field and signature should already be in the symbol | 1887 // passed in) so the field and signature should already be in the symbol |
1895 // table. If they're not there, the field doesn't exist. | 1888 // table. If they're not there, the field doesn't exist. |
1896 symbolHandle fieldname = | 1889 TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name)); |
1897 symbolHandle(THREAD, SymbolTable::probe(name, (int)strlen(name))); | 1890 TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig)); |
1898 symbolHandle signame = | 1891 if (fieldname == NULL || signame == NULL) { |
1899 symbolHandle(THREAD, SymbolTable::probe(sig, (int)strlen(sig))); | |
1900 if (fieldname.is_null() || signame.is_null()) { | |
1901 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); | 1892 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
1902 } | 1893 } |
1903 KlassHandle k(THREAD, | 1894 KlassHandle k(THREAD, |
1904 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); | 1895 java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz))); |
1905 // Make sure class is initialized before handing id's out to static fields | 1896 // Make sure class is initialized before handing id's out to static fields |
1906 Klass::cast(k())->initialize(CHECK_NULL); | 1897 Klass::cast(k())->initialize(CHECK_NULL); |
1907 | 1898 |
1908 fieldDescriptor fd; | 1899 fieldDescriptor fd; |
1909 if (!Klass::cast(k())->oop_is_instance() || | 1900 if (!Klass::cast(k())->oop_is_instance() || |
1910 !instanceKlass::cast(k())->find_field(fieldname(), signame(), true, &fd)) { | 1901 !instanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) { |
1911 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); | 1902 THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name); |
1912 } | 1903 } |
1913 | 1904 |
1914 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the klassOop | 1905 // A jfieldID for a static field is a JNIid specifying the field holder and the offset within the klassOop |
1915 JNIid* id = instanceKlass::cast(fd.field_holder())->jni_id_for(fd.offset()); | 1906 JNIid* id = instanceKlass::cast(fd.field_holder())->jni_id_for(fd.offset()); |
2387 // The RegisterNatives call being attempted tried to register with a method that | 2378 // The RegisterNatives call being attempted tried to register with a method that |
2388 // is not native. Ask JVM TI what prefixes have been specified. Then check | 2379 // is not native. Ask JVM TI what prefixes have been specified. Then check |
2389 // to see if the native method is now wrapped with the prefixes. See the | 2380 // to see if the native method is now wrapped with the prefixes. See the |
2390 // SetNativeMethodPrefix(es) functions in the JVM TI Spec for details. | 2381 // SetNativeMethodPrefix(es) functions in the JVM TI Spec for details. |
2391 static methodOop find_prefixed_native(KlassHandle k, | 2382 static methodOop find_prefixed_native(KlassHandle k, |
2392 symbolHandle name, symbolHandle signature, TRAPS) { | 2383 Symbol* name, Symbol* signature, TRAPS) { |
2393 ResourceMark rm(THREAD); | 2384 ResourceMark rm(THREAD); |
2394 methodOop method; | 2385 methodOop method; |
2395 int name_len = name->utf8_length(); | 2386 int name_len = name->utf8_length(); |
2396 char* name_str = name->as_utf8(); | 2387 char* name_str = name->as_utf8(); |
2397 int prefix_count; | 2388 int prefix_count; |
2403 // try adding this prefix to the method name and see if it matches another method name | 2394 // try adding this prefix to the method name and see if it matches another method name |
2404 int trial_len = name_len + prefix_len; | 2395 int trial_len = name_len + prefix_len; |
2405 char* trial_name_str = NEW_RESOURCE_ARRAY(char, trial_len + 1); | 2396 char* trial_name_str = NEW_RESOURCE_ARRAY(char, trial_len + 1); |
2406 strcpy(trial_name_str, prefix); | 2397 strcpy(trial_name_str, prefix); |
2407 strcat(trial_name_str, name_str); | 2398 strcat(trial_name_str, name_str); |
2408 symbolHandle trial_name(THREAD, SymbolTable::probe(trial_name_str, trial_len)); | 2399 TempNewSymbol trial_name = SymbolTable::probe(trial_name_str, trial_len); |
2409 if (trial_name.is_null()) { | 2400 if (trial_name == NULL) { |
2410 continue; // no such symbol, so this prefix wasn't used, try the next prefix | 2401 continue; // no such symbol, so this prefix wasn't used, try the next prefix |
2411 } | 2402 } |
2412 method = Klass::cast(k())->lookup_method(trial_name(), signature()); | 2403 method = Klass::cast(k())->lookup_method(trial_name, signature); |
2413 if (method == NULL) { | 2404 if (method == NULL) { |
2414 continue; // signature doesn't match, try the next prefix | 2405 continue; // signature doesn't match, try the next prefix |
2415 } | 2406 } |
2416 if (method->is_native()) { | 2407 if (method->is_native()) { |
2417 method->set_is_prefixed_native(); | 2408 method->set_is_prefixed_native(); |
2422 name_str = trial_name_str; | 2413 name_str = trial_name_str; |
2423 } | 2414 } |
2424 return NULL; // not found | 2415 return NULL; // not found |
2425 } | 2416 } |
2426 | 2417 |
2427 static bool register_native(KlassHandle k, symbolHandle name, symbolHandle signature, address entry, TRAPS) { | 2418 static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) { |
2428 methodOop method = Klass::cast(k())->lookup_method(name(), signature()); | 2419 methodOop method = Klass::cast(k())->lookup_method(name, signature); |
2429 if (method == NULL) { | 2420 if (method == NULL) { |
2430 ResourceMark rm; | 2421 ResourceMark rm; |
2431 stringStream st; | 2422 stringStream st; |
2432 st.print("Method %s name or signature does not match", | 2423 st.print("Method %s name or signature does not match", |
2433 methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name(), signature())); | 2424 methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); |
2434 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); | 2425 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
2435 } | 2426 } |
2436 if (!method->is_native()) { | 2427 if (!method->is_native()) { |
2437 // trying to register to a non-native method, see if a JVM TI agent has added prefix(es) | 2428 // trying to register to a non-native method, see if a JVM TI agent has added prefix(es) |
2438 method = find_prefixed_native(k, name, signature, THREAD); | 2429 method = find_prefixed_native(k, name, signature, THREAD); |
2439 if (method == NULL) { | 2430 if (method == NULL) { |
2440 ResourceMark rm; | 2431 ResourceMark rm; |
2441 stringStream st; | 2432 stringStream st; |
2442 st.print("Method %s is not declared as native", | 2433 st.print("Method %s is not declared as native", |
2443 methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name(), signature())); | 2434 methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name, signature)); |
2444 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); | 2435 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false); |
2445 } | 2436 } |
2446 } | 2437 } |
2447 | 2438 |
2448 if (entry != NULL) { | 2439 if (entry != NULL) { |
2478 int meth_name_len = (int)strlen(meth_name); | 2469 int meth_name_len = (int)strlen(meth_name); |
2479 | 2470 |
2480 // The class should have been loaded (we have an instance of the class | 2471 // The class should have been loaded (we have an instance of the class |
2481 // passed in) so the method and signature should already be in the symbol | 2472 // passed in) so the method and signature should already be in the symbol |
2482 // table. If they're not there, the method doesn't exist. | 2473 // table. If they're not there, the method doesn't exist. |
2483 symbolHandle name(THREAD, SymbolTable::probe(meth_name, meth_name_len)); | 2474 TempNewSymbol name = SymbolTable::probe(meth_name, meth_name_len); |
2484 symbolHandle signature(THREAD, SymbolTable::probe(meth_sig, (int)strlen(meth_sig))); | 2475 TempNewSymbol signature = SymbolTable::probe(meth_sig, (int)strlen(meth_sig)); |
2485 | 2476 |
2486 if (name.is_null() || signature.is_null()) { | 2477 if (name == NULL || signature == NULL) { |
2487 ResourceMark rm; | 2478 ResourceMark rm; |
2488 stringStream st; | 2479 stringStream st; |
2489 st.print("Method %s.%s%s not found", Klass::cast(h_k())->external_name(), meth_name, meth_sig); | 2480 st.print("Method %s.%s%s not found", Klass::cast(h_k())->external_name(), meth_name, meth_sig); |
2490 // Must return negative value on failure | 2481 // Must return negative value on failure |
2491 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1); | 2482 THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), -1); |
2715 | 2706 |
2716 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) { | 2707 static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) { |
2717 Handle loader; // null (bootstrap) loader | 2708 Handle loader; // null (bootstrap) loader |
2718 Handle protection_domain; // null protection domain | 2709 Handle protection_domain; // null protection domain |
2719 | 2710 |
2720 symbolHandle sym = oopFactory::new_symbol_handle(name, CHECK_NULL); | 2711 TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); |
2721 jclass result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL); | 2712 jclass result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL); |
2722 | 2713 |
2723 if (TraceClassResolution && result != NULL) { | 2714 if (TraceClassResolution && result != NULL) { |
2724 trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); | 2715 trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result))); |
2725 } | 2716 } |