< prev index next >

src/hotspot/share/prims/jvm.cpp

Print this page

2899   ThreadsListHandle tlh(thread);
2900   JavaThread* receiver = nullptr;
2901   bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, nullptr);
2902   if (is_alive) {
2903     // jthread refers to a live JavaThread.
2904     receiver->interrupt();
2905   }
2906 JVM_END
2907 
2908 // Return true iff the current thread has locked the object passed in
2909 
2910 JVM_ENTRY(jboolean, JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj))
2911   if (obj == nullptr) {
2912     THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE);
2913   }
2914   Handle h_obj(THREAD, JNIHandles::resolve(obj));
2915   return ObjectSynchronizer::current_thread_holds_lock(thread, h_obj);
2916 JVM_END
2917 
2918 JVM_ENTRY(jobject, JVM_GetStackTrace(JNIEnv *env, jobject jthread))

2919   oop trace = java_lang_Thread::async_get_stack_trace(jthread, THREAD);
2920   return JNIHandles::make_local(THREAD, trace);
2921 JVM_END
2922 
2923 JVM_ENTRY(jobject, JVM_CreateThreadSnapshot(JNIEnv* env, jobject jthread))
2924 #if INCLUDE_JVMTI
2925   oop snapshot = ThreadSnapshotFactory::get_thread_snapshot(jthread, THREAD);
2926   return JNIHandles::make_local(THREAD, snapshot);
2927 #else
2928   THROW_NULL(vmSymbols::java_lang_UnsupportedOperationException());
2929 #endif
2930 JVM_END
2931 
2932 JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
2933   // We don't use a ThreadsListHandle here because the current thread
2934   // must be alive.
2935   oop java_thread = JNIHandles::resolve_non_null(jthread);
2936   JavaThread* thr = java_lang_Thread::thread(java_thread);
2937   if (thread == thr && !thr->has_attached_via_jni()) {
2938     // Thread naming is only supported for the current thread and
2939     // we don't set the name of an attached thread to avoid stepping
2940     // on other programs.
2941     ResourceMark rm(thread);
2942     const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
2943     os::set_native_thread_name(thread_name);
2944   }
2945 JVM_END
2946 
2947 JVM_ENTRY(jobject, JVM_ScopedValueCache(JNIEnv* env, jclass threadClass))
2948   oop theCache = thread->scopedValueCache();
2949   return JNIHandles::make_local(THREAD, theCache);

2899   ThreadsListHandle tlh(thread);
2900   JavaThread* receiver = nullptr;
2901   bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &receiver, nullptr);
2902   if (is_alive) {
2903     // jthread refers to a live JavaThread.
2904     receiver->interrupt();
2905   }
2906 JVM_END
2907 
2908 // Return true iff the current thread has locked the object passed in
2909 
2910 JVM_ENTRY(jboolean, JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj))
2911   if (obj == nullptr) {
2912     THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE);
2913   }
2914   Handle h_obj(THREAD, JNIHandles::resolve(obj));
2915   return ObjectSynchronizer::current_thread_holds_lock(thread, h_obj);
2916 JVM_END
2917 
2918 JVM_ENTRY(jobject, JVM_GetStackTrace(JNIEnv *env, jobject jthread))
2919   oop threadObj = JNIHandles::resolve(jthread);
2920   oop trace = java_lang_Thread::async_get_stack_trace(jthread, THREAD);
2921   return JNIHandles::make_local(THREAD, trace);
2922 JVM_END
2923 
2924 JVM_ENTRY(jobject, JVM_CreateThreadSnapshot(JNIEnv* env, jobject jthread, jboolean includeMonitors))
2925   oop snapshot = ThreadSnapshotFactory::get_thread_snapshot(jthread, includeMonitors, THREAD);

2926   return JNIHandles::make_local(THREAD, snapshot);



2927 JVM_END
2928 
2929 JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
2930   // We don't use a ThreadsListHandle here because the current thread
2931   // must be alive.
2932   oop java_thread = JNIHandles::resolve_non_null(jthread);
2933   JavaThread* thr = java_lang_Thread::thread(java_thread);
2934   if (thread == thr && !thr->has_attached_via_jni()) {
2935     // Thread naming is only supported for the current thread and
2936     // we don't set the name of an attached thread to avoid stepping
2937     // on other programs.
2938     ResourceMark rm(thread);
2939     const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
2940     os::set_native_thread_name(thread_name);
2941   }
2942 JVM_END
2943 
2944 JVM_ENTRY(jobject, JVM_ScopedValueCache(JNIEnv* env, jclass threadClass))
2945   oop theCache = thread->scopedValueCache();
2946   return JNIHandles::make_local(THREAD, theCache);
< prev index next >