529 |
530 |
530 |
531 |
531 |
532 |
532 // java.lang.Throwable ////////////////////////////////////////////////////// |
533 // java.lang.Throwable ////////////////////////////////////////////////////// |
533 |
534 |
534 |
|
535 JVM_ENTRY(void, JVM_FillInStackTrace(JNIEnv *env, jobject receiver)) |
535 JVM_ENTRY(void, JVM_FillInStackTrace(JNIEnv *env, jobject receiver)) |
536 JVMWrapper("JVM_FillInStackTrace"); |
536 JVMWrapper("JVM_FillInStackTrace"); |
537 Handle exception(thread, JNIHandles::resolve_non_null(receiver)); |
537 Handle exception(thread, JNIHandles::resolve_non_null(receiver)); |
538 java_lang_Throwable::fill_in_stack_trace(exception); |
538 java_lang_Throwable::fill_in_stack_trace(exception); |
539 JVM_END |
539 JVM_END |
540 |
540 |
|
541 // java.lang.NullPointerException /////////////////////////////////////////// |
|
542 |
|
543 JVM_ENTRY(jstring, JVM_GetExtendedNPEMessage(JNIEnv *env, jthrowable throwable)) |
|
544 if (!ShowCodeDetailsInExceptionMessages) return NULL; |
|
545 |
|
546 oop exc = JNIHandles::resolve_non_null(throwable); |
|
547 |
|
548 Method* method; |
|
549 int bci; |
|
550 if (!java_lang_Throwable::get_top_method_and_bci(exc, &method, &bci)) { |
|
551 return NULL; |
|
552 } |
|
553 if (method->is_native()) { |
|
554 return NULL; |
|
555 } |
|
556 |
|
557 stringStream ss; |
|
558 bool ok = BytecodeUtils::get_NPE_message_at(&ss, method, bci); |
|
559 if (ok) { |
|
560 oop result = java_lang_String::create_oop_from_str(ss.base(), CHECK_0); |
|
561 return (jstring) JNIHandles::make_local(env, result); |
|
562 } else { |
|
563 return NULL; |
|
564 } |
|
565 JVM_END |
541 |
566 |
542 // java.lang.StackTraceElement ////////////////////////////////////////////// |
567 // java.lang.StackTraceElement ////////////////////////////////////////////// |
543 |
568 |
544 |
569 |
545 JVM_ENTRY(void, JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable)) |
570 JVM_ENTRY(void, JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable)) |
976 JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)) |
1013 JVM_ENTRY(jclass, JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name)) |
977 JVMWrapper("JVM_FindLoadedClass"); |
1014 JVMWrapper("JVM_FindLoadedClass"); |
978 ResourceMark rm(THREAD); |
1015 ResourceMark rm(THREAD); |
979 |
1016 |
980 Handle h_name (THREAD, JNIHandles::resolve_non_null(name)); |
1017 Handle h_name (THREAD, JNIHandles::resolve_non_null(name)); |
981 Handle string = java_lang_String::internalize_classname(h_name, CHECK_NULL); |
1018 char* str = java_lang_String::as_utf8_string(h_name()); |
982 |
1019 |
983 const char* str = java_lang_String::as_utf8_string(string()); |
|
984 // Sanity check, don't expect null |
1020 // Sanity check, don't expect null |
985 if (str == NULL) return NULL; |
1021 if (str == NULL) return NULL; |
986 |
1022 |
987 const int str_len = (int)strlen(str); |
1023 // Internalize the string, converting '.' to '/' in string. |
|
1024 char* p = (char*)str; |
|
1025 while (*p != '\0') { |
|
1026 if (*p == '.') { |
|
1027 *p = '/'; |
|
1028 } |
|
1029 p++; |
|
1030 } |
|
1031 |
|
1032 const int str_len = (int)(p - str); |
988 if (str_len > Symbol::max_length()) { |
1033 if (str_len > Symbol::max_length()) { |
989 // It's impossible to create this class; the name cannot fit |
1034 // It's impossible to create this class; the name cannot fit |
990 // into the constant pool. |
1035 // into the constant pool. |
991 return NULL; |
1036 return NULL; |
992 } |
1037 } |
2267 } |
2312 } |
2268 } |
2313 } |
2269 JVM_END |
2314 JVM_END |
2270 |
2315 |
2271 |
2316 |
2272 JVM_QUICK_ENTRY(jint, JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)) |
2317 JVM_ENTRY(jint, JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cls)) |
2273 JVMWrapper("JVM_GetClassCPEntriesCount"); |
2318 JVMWrapper("JVM_GetClassCPEntriesCount"); |
2274 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2319 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2275 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2320 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2276 return (!k->is_instance_klass()) ? 0 : InstanceKlass::cast(k)->constants()->length(); |
2321 return (!k->is_instance_klass()) ? 0 : InstanceKlass::cast(k)->constants()->length(); |
2277 JVM_END |
2322 JVM_END |
2278 |
2323 |
2279 |
2324 |
2280 JVM_QUICK_ENTRY(jint, JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)) |
2325 JVM_ENTRY(jint, JVM_GetClassFieldsCount(JNIEnv *env, jclass cls)) |
2281 JVMWrapper("JVM_GetClassFieldsCount"); |
2326 JVMWrapper("JVM_GetClassFieldsCount"); |
2282 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2327 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2283 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2328 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2284 return (!k->is_instance_klass()) ? 0 : InstanceKlass::cast(k)->java_fields_count(); |
2329 return (!k->is_instance_klass()) ? 0 : InstanceKlass::cast(k)->java_fields_count(); |
2285 JVM_END |
2330 JVM_END |
2286 |
2331 |
2287 |
2332 |
2288 JVM_QUICK_ENTRY(jint, JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)) |
2333 JVM_ENTRY(jint, JVM_GetClassMethodsCount(JNIEnv *env, jclass cls)) |
2289 JVMWrapper("JVM_GetClassMethodsCount"); |
2334 JVMWrapper("JVM_GetClassMethodsCount"); |
2290 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2335 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2291 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2336 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2292 return (!k->is_instance_klass()) ? 0 : InstanceKlass::cast(k)->methods()->length(); |
2337 return (!k->is_instance_klass()) ? 0 : InstanceKlass::cast(k)->methods()->length(); |
2293 JVM_END |
2338 JVM_END |
2296 // The following methods, used for the verifier, are never called with |
2341 // The following methods, used for the verifier, are never called with |
2297 // array klasses, so a direct cast to InstanceKlass is safe. |
2342 // array klasses, so a direct cast to InstanceKlass is safe. |
2298 // Typically, these methods are called in a loop with bounds determined |
2343 // Typically, these methods are called in a loop with bounds determined |
2299 // by the results of JVM_GetClass{Fields,Methods}Count, which return |
2344 // by the results of JVM_GetClass{Fields,Methods}Count, which return |
2300 // zero for arrays. |
2345 // zero for arrays. |
2301 JVM_QUICK_ENTRY(void, JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)) |
2346 JVM_ENTRY(void, JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cls, jint method_index, unsigned short *exceptions)) |
2302 JVMWrapper("JVM_GetMethodIxExceptionIndexes"); |
2347 JVMWrapper("JVM_GetMethodIxExceptionIndexes"); |
2303 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2348 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2304 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2349 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2305 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2350 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2306 int length = method->checked_exceptions_length(); |
2351 int length = method->checked_exceptions_length(); |
2311 } |
2356 } |
2312 } |
2357 } |
2313 JVM_END |
2358 JVM_END |
2314 |
2359 |
2315 |
2360 |
2316 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)) |
2361 JVM_ENTRY(jint, JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cls, jint method_index)) |
2317 JVMWrapper("JVM_GetMethodIxExceptionsCount"); |
2362 JVMWrapper("JVM_GetMethodIxExceptionsCount"); |
2318 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2363 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2319 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2364 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2320 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2365 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2321 return method->checked_exceptions_length(); |
2366 return method->checked_exceptions_length(); |
2322 JVM_END |
2367 JVM_END |
2323 |
2368 |
2324 |
2369 |
2325 JVM_QUICK_ENTRY(void, JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)) |
2370 JVM_ENTRY(void, JVM_GetMethodIxByteCode(JNIEnv *env, jclass cls, jint method_index, unsigned char *code)) |
2326 JVMWrapper("JVM_GetMethodIxByteCode"); |
2371 JVMWrapper("JVM_GetMethodIxByteCode"); |
2327 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2372 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2328 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2373 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2329 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2374 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2330 memcpy(code, method->code_base(), method->code_size()); |
2375 memcpy(code, method->code_base(), method->code_size()); |
2331 JVM_END |
2376 JVM_END |
2332 |
2377 |
2333 |
2378 |
2334 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)) |
2379 JVM_ENTRY(jint, JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cls, jint method_index)) |
2335 JVMWrapper("JVM_GetMethodIxByteCodeLength"); |
2380 JVMWrapper("JVM_GetMethodIxByteCodeLength"); |
2336 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2381 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2337 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2382 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2338 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2383 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2339 return method->code_size(); |
2384 return method->code_size(); |
2340 JVM_END |
2385 JVM_END |
2341 |
2386 |
2342 |
2387 |
2343 JVM_QUICK_ENTRY(void, JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)) |
2388 JVM_ENTRY(void, JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cls, jint method_index, jint entry_index, JVM_ExceptionTableEntryType *entry)) |
2344 JVMWrapper("JVM_GetMethodIxExceptionTableEntry"); |
2389 JVMWrapper("JVM_GetMethodIxExceptionTableEntry"); |
2345 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2390 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2346 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2391 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2347 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2392 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2348 ExceptionTable extable(method); |
2393 ExceptionTable extable(method); |
2351 entry->handler_pc = extable.handler_pc(entry_index); |
2396 entry->handler_pc = extable.handler_pc(entry_index); |
2352 entry->catchType = extable.catch_type_index(entry_index); |
2397 entry->catchType = extable.catch_type_index(entry_index); |
2353 JVM_END |
2398 JVM_END |
2354 |
2399 |
2355 |
2400 |
2356 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)) |
2401 JVM_ENTRY(jint, JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cls, int method_index)) |
2357 JVMWrapper("JVM_GetMethodIxExceptionTableLength"); |
2402 JVMWrapper("JVM_GetMethodIxExceptionTableLength"); |
2358 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2403 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2359 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2404 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2360 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2405 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2361 return method->exception_table_length(); |
2406 return method->exception_table_length(); |
2362 JVM_END |
2407 JVM_END |
2363 |
2408 |
2364 |
2409 |
2365 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)) |
2410 JVM_ENTRY(jint, JVM_GetMethodIxModifiers(JNIEnv *env, jclass cls, int method_index)) |
2366 JVMWrapper("JVM_GetMethodIxModifiers"); |
2411 JVMWrapper("JVM_GetMethodIxModifiers"); |
2367 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2412 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2368 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2413 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2369 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2414 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2370 return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; |
2415 return method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS; |
2371 JVM_END |
2416 JVM_END |
2372 |
2417 |
2373 |
2418 |
2374 JVM_QUICK_ENTRY(jint, JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)) |
2419 JVM_ENTRY(jint, JVM_GetFieldIxModifiers(JNIEnv *env, jclass cls, int field_index)) |
2375 JVMWrapper("JVM_GetFieldIxModifiers"); |
2420 JVMWrapper("JVM_GetFieldIxModifiers"); |
2376 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2421 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2377 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2422 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2378 return InstanceKlass::cast(k)->field_access_flags(field_index) & JVM_RECOGNIZED_FIELD_MODIFIERS; |
2423 return InstanceKlass::cast(k)->field_access_flags(field_index) & JVM_RECOGNIZED_FIELD_MODIFIERS; |
2379 JVM_END |
2424 JVM_END |
2380 |
2425 |
2381 |
2426 |
2382 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)) |
2427 JVM_ENTRY(jint, JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cls, int method_index)) |
2383 JVMWrapper("JVM_GetMethodIxLocalsCount"); |
2428 JVMWrapper("JVM_GetMethodIxLocalsCount"); |
2384 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2429 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2385 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2430 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2386 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2431 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2387 return method->max_locals(); |
2432 return method->max_locals(); |
2388 JVM_END |
2433 JVM_END |
2389 |
2434 |
2390 |
2435 |
2391 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)) |
2436 JVM_ENTRY(jint, JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cls, int method_index)) |
2392 JVMWrapper("JVM_GetMethodIxArgsSize"); |
2437 JVMWrapper("JVM_GetMethodIxArgsSize"); |
2393 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2438 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2394 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2439 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2395 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2440 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2396 return method->size_of_parameters(); |
2441 return method->size_of_parameters(); |
2397 JVM_END |
2442 JVM_END |
2398 |
2443 |
2399 |
2444 |
2400 JVM_QUICK_ENTRY(jint, JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)) |
2445 JVM_ENTRY(jint, JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cls, int method_index)) |
2401 JVMWrapper("JVM_GetMethodIxMaxStack"); |
2446 JVMWrapper("JVM_GetMethodIxMaxStack"); |
2402 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2447 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2403 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2448 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2404 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2449 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2405 return method->verifier_max_stack(); |
2450 return method->verifier_max_stack(); |
2406 JVM_END |
2451 JVM_END |
2407 |
2452 |
2408 |
2453 |
2409 JVM_QUICK_ENTRY(jboolean, JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)) |
2454 JVM_ENTRY(jboolean, JVM_IsConstructorIx(JNIEnv *env, jclass cls, int method_index)) |
2410 JVMWrapper("JVM_IsConstructorIx"); |
2455 JVMWrapper("JVM_IsConstructorIx"); |
2411 ResourceMark rm(THREAD); |
2456 ResourceMark rm(THREAD); |
2412 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2457 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2413 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2458 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2414 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2459 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2415 return method->name() == vmSymbols::object_initializer_name(); |
2460 return method->name() == vmSymbols::object_initializer_name(); |
2416 JVM_END |
2461 JVM_END |
2417 |
2462 |
2418 |
2463 |
2419 JVM_QUICK_ENTRY(jboolean, JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cls, int method_index)) |
2464 JVM_ENTRY(jboolean, JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cls, int method_index)) |
2420 JVMWrapper("JVM_IsVMGeneratedMethodIx"); |
2465 JVMWrapper("JVM_IsVMGeneratedMethodIx"); |
2421 ResourceMark rm(THREAD); |
2466 ResourceMark rm(THREAD); |
2422 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2467 Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls)); |
2423 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2468 k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread); |
2424 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
2469 Method* method = InstanceKlass::cast(k)->methods()->at(method_index); |
3057 ThreadsListHandle tlh(thread); |
3102 ThreadsListHandle tlh(thread); |
3058 JavaThread* receiver = NULL; |
3103 JavaThread* receiver = NULL; |
3059 bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, NULL); |
3104 bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, NULL); |
3060 if (is_alive) { |
3105 if (is_alive) { |
3061 // jthread refers to a live JavaThread. |
3106 // jthread refers to a live JavaThread. |
3062 Thread::interrupt(receiver); |
3107 receiver->interrupt(); |
3063 } |
3108 } |
3064 JVM_END |
3109 JVM_END |
3065 |
3110 |
3066 |
3111 |
3067 JVM_QUICK_ENTRY(jboolean, JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted)) |
3112 JVM_ENTRY(jboolean, JVM_IsInterrupted(JNIEnv* env, jobject jthread, jboolean clear_interrupted)) |
3068 JVMWrapper("JVM_IsInterrupted"); |
3113 JVMWrapper("JVM_IsInterrupted"); |
3069 |
3114 |
3070 ThreadsListHandle tlh(thread); |
3115 ThreadsListHandle tlh(thread); |
3071 JavaThread* receiver = NULL; |
3116 JavaThread* receiver = NULL; |
3072 bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, NULL); |
3117 bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, NULL); |
3073 if (is_alive) { |
3118 if (is_alive) { |
3074 // jthread refers to a live JavaThread. |
3119 // jthread refers to a live JavaThread. |
3075 return (jboolean) Thread::is_interrupted(receiver, clear_interrupted != 0); |
3120 return (jboolean) receiver->is_interrupted(clear_interrupted != 0); |
3076 } else { |
3121 } else { |
3077 return JNI_FALSE; |
3122 return JNI_FALSE; |
3078 } |
3123 } |
3079 JVM_END |
3124 JVM_END |
3080 |
3125 |
3382 oop result = StringTable::intern(string, CHECK_NULL); |
3427 oop result = StringTable::intern(string, CHECK_NULL); |
3383 return (jstring) JNIHandles::make_local(env, result); |
3428 return (jstring) JNIHandles::make_local(env, result); |
3384 JVM_END |
3429 JVM_END |
3385 |
3430 |
3386 |
3431 |
3387 // Raw monitor support ////////////////////////////////////////////////////////////////////// |
3432 // VM Raw monitor support ////////////////////////////////////////////////////////////////////// |
3388 |
3433 |
3389 // The lock routine below calls lock_without_safepoint_check in order to get a raw lock |
3434 // VM Raw monitors (not to be confused with JvmtiRawMonitors) are a simple mutual exclusion |
3390 // without interfering with the safepoint mechanism. The routines are not JVM_LEAF because |
3435 // lock (not actually monitors: no wait/notify) that is exported by the VM for use by JDK |
3391 // they might be called by non-java threads. The JVM_LEAF installs a NoHandleMark check |
3436 // library code. They may be used by JavaThreads and non-JavaThreads and do not participate |
3392 // that only works with java threads. |
3437 // in the safepoint protocol, thread suspension, thread interruption, or anything of that |
|
3438 // nature. JavaThreads will be "in native" when using this API from JDK code. |
3393 |
3439 |
3394 |
3440 |
3395 JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void) { |
3441 JNIEXPORT void* JNICALL JVM_RawMonitorCreate(void) { |
3396 VM_Exit::block_if_vm_exited(); |
3442 VM_Exit::block_if_vm_exited(); |
3397 JVMWrapper("JVM_RawMonitorCreate"); |
3443 JVMWrapper("JVM_RawMonitorCreate"); |
3398 return new Mutex(Mutex::native, "JVM_RawMonitorCreate"); |
3444 return new os::PlatformMutex(); |
3399 } |
3445 } |
3400 |
3446 |
3401 |
3447 |
3402 JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon) { |
3448 JNIEXPORT void JNICALL JVM_RawMonitorDestroy(void *mon) { |
3403 VM_Exit::block_if_vm_exited(); |
3449 VM_Exit::block_if_vm_exited(); |
3404 JVMWrapper("JVM_RawMonitorDestroy"); |
3450 JVMWrapper("JVM_RawMonitorDestroy"); |
3405 delete ((Mutex*) mon); |
3451 delete ((os::PlatformMutex*) mon); |
3406 } |
3452 } |
3407 |
3453 |
3408 |
3454 |
3409 JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon) { |
3455 JNIEXPORT jint JNICALL JVM_RawMonitorEnter(void *mon) { |
3410 VM_Exit::block_if_vm_exited(); |
3456 VM_Exit::block_if_vm_exited(); |
3411 JVMWrapper("JVM_RawMonitorEnter"); |
3457 JVMWrapper("JVM_RawMonitorEnter"); |
3412 ((Mutex*) mon)->jvm_raw_lock(); |
3458 ((os::PlatformMutex*) mon)->lock(); |
3413 return 0; |
3459 return 0; |
3414 } |
3460 } |
3415 |
3461 |
3416 |
3462 |
3417 JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon) { |
3463 JNIEXPORT void JNICALL JVM_RawMonitorExit(void *mon) { |
3418 VM_Exit::block_if_vm_exited(); |
3464 VM_Exit::block_if_vm_exited(); |
3419 JVMWrapper("JVM_RawMonitorExit"); |
3465 JVMWrapper("JVM_RawMonitorExit"); |
3420 ((Mutex*) mon)->jvm_raw_unlock(); |
3466 ((os::PlatformMutex*) mon)->unlock(); |
3421 } |
3467 } |
3422 |
3468 |
3423 |
3469 |
3424 // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// |
3470 // Shared JNI/JVM entry points ////////////////////////////////////////////////////////////// |
3425 |
3471 |
3426 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, |
3472 jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, jboolean link, |
3427 Handle loader, Handle protection_domain, |
3473 Handle loader, Handle protection_domain, |
3428 jboolean throwError, TRAPS) { |
3474 jboolean throwError, TRAPS) { |
|
3475 // Initialization also implies linking - check for coherent args |
|
3476 assert((init && link) || !init, "incorrect use of init/link arguments"); |
|
3477 |
3429 // Security Note: |
3478 // Security Note: |
3430 // The Java level wrapper will perform the necessary security check allowing |
3479 // The Java level wrapper will perform the necessary security check allowing |
3431 // us to pass the NULL as the initiating class loader. The VM is responsible for |
3480 // us to pass the NULL as the initiating class loader. The VM is responsible for |
3432 // the checkPackageAccess relative to the initiating class loader via the |
3481 // the checkPackageAccess relative to the initiating class loader via the |
3433 // protection_domain. The protection_domain is passed as NULL by the java code |
3482 // protection_domain. The protection_domain is passed as NULL by the java code |
3434 // if there is no security manager in 3-arg Class.forName(). |
3483 // if there is no security manager in 3-arg Class.forName(). |
3435 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
3484 Klass* klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL); |
3436 |
3485 |
3437 // Check if we should initialize the class |
3486 // Check if we should initialize the class (which implies linking), or just link it |
3438 if (init && klass->is_instance_klass()) { |
3487 if (init && klass->is_instance_klass()) { |
3439 klass->initialize(CHECK_NULL); |
3488 klass->initialize(CHECK_NULL); |
|
3489 } else if (link && klass->is_instance_klass()) { |
|
3490 InstanceKlass::cast(klass)->link_class(CHECK_NULL); |
3440 } |
3491 } |
3441 return (jclass) JNIHandles::make_local(env, klass->java_mirror()); |
3492 return (jclass) JNIHandles::make_local(env, klass->java_mirror()); |
3442 } |
3493 } |
3443 |
3494 |
3444 |
3495 |