2898 // jthread refers to a live JavaThread.
2899 receiver->interrupt();
2900 }
2901 JVM_END
2902
2903 // Return true iff the current thread has locked the object passed in
2904
2905 JVM_ENTRY(jboolean, JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj))
2906 if (obj == nullptr) {
2907 THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE);
2908 }
2909 Handle h_obj(THREAD, JNIHandles::resolve(obj));
2910 return ObjectSynchronizer::current_thread_holds_lock(thread, h_obj);
2911 JVM_END
2912
2913 JVM_ENTRY(jobject, JVM_GetStackTrace(JNIEnv *env, jobject jthread))
2914 oop trace = java_lang_Thread::async_get_stack_trace(jthread, THREAD);
2915 return JNIHandles::make_local(THREAD, trace);
2916 JVM_END
2917
2918 JVM_ENTRY(jobject, JVM_CreateThreadSnapshot(JNIEnv* env, jobject jthread))
2919 #if INCLUDE_JVMTI
2920 oop snapshot = ThreadSnapshotFactory::get_thread_snapshot(jthread, THREAD);
2921 return JNIHandles::make_local(THREAD, snapshot);
2922 #else
2923 THROW_NULL(vmSymbols::java_lang_UnsupportedOperationException());
2924 #endif
2925 JVM_END
2926
2927 JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
2928 // We don't use a ThreadsListHandle here because the current thread
2929 // must be alive.
2930 oop java_thread = JNIHandles::resolve_non_null(jthread);
2931 JavaThread* thr = java_lang_Thread::thread(java_thread);
2932 if (thread == thr && !thr->has_attached_via_jni()) {
2933 // Thread naming is only supported for the current thread and
2934 // we don't set the name of an attached thread to avoid stepping
2935 // on other programs.
2936 ResourceMark rm(thread);
2937 const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
2938 os::set_native_thread_name(thread_name);
2939 }
2940 JVM_END
2941
2942 JVM_ENTRY(jobject, JVM_ScopedValueCache(JNIEnv* env, jclass threadClass))
2943 oop theCache = thread->scopedValueCache();
2944 return JNIHandles::make_local(THREAD, theCache);
|
2898 // jthread refers to a live JavaThread.
2899 receiver->interrupt();
2900 }
2901 JVM_END
2902
2903 // Return true iff the current thread has locked the object passed in
2904
2905 JVM_ENTRY(jboolean, JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj))
2906 if (obj == nullptr) {
2907 THROW_(vmSymbols::java_lang_NullPointerException(), JNI_FALSE);
2908 }
2909 Handle h_obj(THREAD, JNIHandles::resolve(obj));
2910 return ObjectSynchronizer::current_thread_holds_lock(thread, h_obj);
2911 JVM_END
2912
2913 JVM_ENTRY(jobject, JVM_GetStackTrace(JNIEnv *env, jobject jthread))
2914 oop trace = java_lang_Thread::async_get_stack_trace(jthread, THREAD);
2915 return JNIHandles::make_local(THREAD, trace);
2916 JVM_END
2917
2918 JVM_ENTRY(jobject, JVM_CreateThreadSnapshot(JNIEnv* env, jobject jthread, jboolean includeMonitors))
2919 oop snapshot = ThreadSnapshotFactory::get_thread_snapshot(jthread, includeMonitors, THREAD);
2920 return JNIHandles::make_local(THREAD, snapshot);
2921 JVM_END
2922
2923 JVM_ENTRY(void, JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name))
2924 // We don't use a ThreadsListHandle here because the current thread
2925 // must be alive.
2926 oop java_thread = JNIHandles::resolve_non_null(jthread);
2927 JavaThread* thr = java_lang_Thread::thread(java_thread);
2928 if (thread == thr && !thr->has_attached_via_jni()) {
2929 // Thread naming is only supported for the current thread and
2930 // we don't set the name of an attached thread to avoid stepping
2931 // on other programs.
2932 ResourceMark rm(thread);
2933 const char *thread_name = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(name));
2934 os::set_native_thread_name(thread_name);
2935 }
2936 JVM_END
2937
2938 JVM_ENTRY(jobject, JVM_ScopedValueCache(JNIEnv* env, jclass threadClass))
2939 oop theCache = thread->scopedValueCache();
2940 return JNIHandles::make_local(THREAD, theCache);
|