877 state |= JVMTI_THREAD_STATE_SUSPENDED; |
877 state |= JVMTI_THREAD_STATE_SUSPENDED; |
878 } |
878 } |
879 if (jts == _thread_in_native) { |
879 if (jts == _thread_in_native) { |
880 state |= JVMTI_THREAD_STATE_IN_NATIVE; |
880 state |= JVMTI_THREAD_STATE_IN_NATIVE; |
881 } |
881 } |
882 OSThread* osThread = java_thread->osthread(); |
882 if (java_thread->is_interrupted(false)) { |
883 if (osThread != NULL && osThread->interrupted()) { |
|
884 state |= JVMTI_THREAD_STATE_INTERRUPTED; |
883 state |= JVMTI_THREAD_STATE_INTERRUPTED; |
885 } |
884 } |
886 } |
885 } |
887 |
886 |
888 *thread_state_ptr = state; |
887 *thread_state_ptr = state; |
1090 |
1089 |
1091 // Threads_lock NOT held |
1090 // Threads_lock NOT held |
1092 // thread - NOT pre-checked |
1091 // thread - NOT pre-checked |
1093 jvmtiError |
1092 jvmtiError |
1094 JvmtiEnv::InterruptThread(jthread thread) { |
1093 JvmtiEnv::InterruptThread(jthread thread) { |
1095 // TODO: this is very similar to JVM_Interrupt(); share code in future |
|
1096 JavaThread* current_thread = JavaThread::current(); |
1094 JavaThread* current_thread = JavaThread::current(); |
1097 JavaThread* java_thread = NULL; |
1095 JavaThread* java_thread = NULL; |
1098 ThreadsListHandle tlh(current_thread); |
1096 ThreadsListHandle tlh(current_thread); |
1099 jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), thread, &java_thread, NULL); |
1097 jvmtiError err = JvmtiExport::cv_external_thread_to_JavaThread(tlh.list(), thread, &java_thread, NULL); |
1100 if (err != JVMTI_ERROR_NONE) { |
1098 if (err != JVMTI_ERROR_NONE) { |
1101 return err; |
1099 return err; |
1102 } |
1100 } |
1103 |
1101 // Really this should be a Java call to Thread.interrupt to ensure the same |
|
1102 // semantics, however historically this has not been done for some reason. |
|
1103 // So we continue with that (which means we don't interact with any Java-level |
|
1104 // Interruptible object) but we must set the Java-level interrupted state. |
|
1105 java_lang_Thread::set_interrupted(JNIHandles::resolve(thread), true); |
1104 java_thread->interrupt(); |
1106 java_thread->interrupt(); |
1105 |
1107 |
1106 return JVMTI_ERROR_NONE; |
1108 return JVMTI_ERROR_NONE; |
1107 } /* end InterruptThread */ |
1109 } /* end InterruptThread */ |
1108 |
1110 |