src/share/vm/prims/jvmtiTrace.cpp

Print this page




 249       return names[index];
 250     }
 251   }
 252   return "*INVALID-ENUM-VALUE*";
 253 }
 254 
 255 
 256 // return a valid string no matter what state the thread is in
 257 const char *JvmtiTrace::safe_get_thread_name(Thread *thread) {
 258   if (thread == NULL) {
 259     return "NULL";
 260   }
 261   if (!thread->is_Java_thread()) {
 262     return thread->name();
 263   }
 264   JavaThread *java_thread = (JavaThread *)thread;
 265   oop threadObj = java_thread->threadObj();
 266   if (threadObj == NULL) {
 267     return "NULL";
 268   }
 269   typeArrayOop name = java_lang_Thread::name(threadObj);
 270   if (name == NULL) {
 271     return "<NOT FILLED IN>";
 272   }
 273   return UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length());
 274 }
 275 
 276 
 277 // return the name of the current thread
 278 const char *JvmtiTrace::safe_get_current_thread_name() {
 279   if (JvmtiEnv::is_vm_live()) {
 280     return JvmtiTrace::safe_get_thread_name(Thread::current());
 281   } else {
 282     return "VM not live";
 283   }
 284 }
 285 
 286 // return a valid string no matter what the state of k_mirror
 287 const char * JvmtiTrace::get_class_name(oop k_mirror) {
 288   if (java_lang_Class::is_primitive(k_mirror)) {
 289     return "primitive";
 290   }
 291   Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
 292   if (k_oop == NULL) {
 293     return "INVALID";


 249       return names[index];
 250     }
 251   }
 252   return "*INVALID-ENUM-VALUE*";
 253 }
 254 
 255 
 256 // return a valid string no matter what state the thread is in
 257 const char *JvmtiTrace::safe_get_thread_name(Thread *thread) {
 258   if (thread == NULL) {
 259     return "NULL";
 260   }
 261   if (!thread->is_Java_thread()) {
 262     return thread->name();
 263   }
 264   JavaThread *java_thread = (JavaThread *)thread;
 265   oop threadObj = java_thread->threadObj();
 266   if (threadObj == NULL) {
 267     return "NULL";
 268   }
 269   oop name = java_lang_Thread::name(threadObj);
 270   if (name == NULL) {
 271     return "<NOT FILLED IN>";
 272   }
 273   return java_lang_String::as_utf8_string(name);
 274 }
 275 
 276 
 277 // return the name of the current thread
 278 const char *JvmtiTrace::safe_get_current_thread_name() {
 279   if (JvmtiEnv::is_vm_live()) {
 280     return JvmtiTrace::safe_get_thread_name(Thread::current());
 281   } else {
 282     return "VM not live";
 283   }
 284 }
 285 
 286 // return a valid string no matter what the state of k_mirror
 287 const char * JvmtiTrace::get_class_name(oop k_mirror) {
 288   if (java_lang_Class::is_primitive(k_mirror)) {
 289     return "primitive";
 290   }
 291   Klass* k_oop = java_lang_Class::as_Klass(k_mirror);
 292   if (k_oop == NULL) {
 293     return "INVALID";