< prev index next >

src/hotspot/share/prims/jvmtiTrace.cpp

Print this page

260 
261 
262 const char* JvmtiTrace::enum_name(const char** names, const jint* values, jint value) {
263   for (int index = 0; names[index] != 0; ++index) {
264     if (values[index] == value) {
265       return names[index];
266     }
267   }
268   return "*INVALID-ENUM-VALUE*";
269 }
270 
271 
272 // return a valid string no matter what state the thread is in
273 const char *JvmtiTrace::safe_get_thread_name(Thread *thread) {
274   if (thread == NULL) {
275     return "NULL";
276   }
277   if (!thread->is_Java_thread()) {
278     return thread->name();
279   }
280   oop threadObj = JavaThread::cast(thread)->threadObj();




281   if (threadObj == NULL) {
282     return "NULL";
283   }
284   oop name = java_lang_Thread::name(threadObj);
285   if (name == NULL) {
286     return "<NOT FILLED IN>";
287   }
288   return java_lang_String::as_utf8_string(name);
289 }
290 
291 
292 // return the name of the current thread
293 const char *JvmtiTrace::safe_get_current_thread_name() {
294   if (JvmtiEnv::is_vm_live()) {
295     return JvmtiTrace::safe_get_thread_name(Thread::current_or_null());
296   } else {
297     return "VM not live";
298   }
299 }
300 

260 
261 
262 const char* JvmtiTrace::enum_name(const char** names, const jint* values, jint value) {
263   for (int index = 0; names[index] != 0; ++index) {
264     if (values[index] == value) {
265       return names[index];
266     }
267   }
268   return "*INVALID-ENUM-VALUE*";
269 }
270 
271 
272 // return a valid string no matter what state the thread is in
273 const char *JvmtiTrace::safe_get_thread_name(Thread *thread) {
274   if (thread == NULL) {
275     return "NULL";
276   }
277   if (!thread->is_Java_thread()) {
278     return thread->name();
279   }
280   JavaThread* java_thread = JavaThread::cast(thread);
281   oop threadObj = java_thread->mounted_vthread();
282   if (threadObj == NULL) {
283     threadObj = java_thread->threadObj();
284   }
285   if (threadObj == NULL) {
286     return "NULL";
287   }
288   oop name = java_lang_Thread::name(threadObj);
289   if (name == NULL) {
290     return "<NOT FILLED IN>";
291   }
292   return java_lang_String::as_utf8_string(name);
293 }
294 
295 
296 // return the name of the current thread
297 const char *JvmtiTrace::safe_get_current_thread_name() {
298   if (JvmtiEnv::is_vm_live()) {
299     return JvmtiTrace::safe_get_thread_name(Thread::current_or_null());
300   } else {
301     return "VM not live";
302   }
303 }
304 
< prev index next >