< prev index next >

src/hotspot/share/prims/jvm.cpp

Print this page

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

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





2916 JVM_ENTRY(jobject, JVM_CreateThreadSnapshot(JNIEnv* env, jobject jthread))

2917   oop snapshot = ThreadSnapshotFactory::get_thread_snapshot(jthread, THREAD);
2918   return JNIHandles::make_local(THREAD, snapshot);



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