2916 } 2917 } else if (is_attaching_via_jni()) { // workaround for 6412693 - see 6404306 2918 name_str = "<no-name - thread is attaching>"; 2919 } else { 2920 name_str = Thread::name(); 2921 } 2922 } else { 2923 name_str = Thread::name(); 2924 } 2925 assert(name_str != NULL, "unexpected NULL thread name"); 2926 return name_str; 2927 } 2928 2929 2930 const char* JavaThread::get_threadgroup_name() const { 2931 debug_only(if (JavaThread::current() != this) assert_locked_or_safepoint(Threads_lock);) 2932 oop thread_obj = threadObj(); 2933 if (thread_obj != NULL) { 2934 oop thread_group = java_lang_Thread::threadGroup(thread_obj); 2935 if (thread_group != NULL) { 2936 typeArrayOop name = java_lang_ThreadGroup::name(thread_group); 2937 // ThreadGroup.name can be null 2938 if (name != NULL) { 2939 const char* str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length()); 2940 return str; 2941 } 2942 } 2943 } 2944 return NULL; 2945 } 2946 2947 const char* JavaThread::get_parent_name() const { 2948 debug_only(if (JavaThread::current() != this) assert_locked_or_safepoint(Threads_lock);) 2949 oop thread_obj = threadObj(); 2950 if (thread_obj != NULL) { 2951 oop thread_group = java_lang_Thread::threadGroup(thread_obj); 2952 if (thread_group != NULL) { 2953 oop parent = java_lang_ThreadGroup::parent(thread_group); 2954 if (parent != NULL) { 2955 typeArrayOop name = java_lang_ThreadGroup::name(parent); 2956 // ThreadGroup.name can be null 2957 if (name != NULL) { 2958 const char* str = UNICODE::as_utf8((jchar*) name->base(T_CHAR), name->length()); 2959 return str; 2960 } 2961 } 2962 } 2963 } 2964 return NULL; 2965 } 2966 2967 ThreadPriority JavaThread::java_priority() const { 2968 oop thr_oop = threadObj(); 2969 if (thr_oop == NULL) return NormPriority; // Bootstrapping 2970 ThreadPriority priority = java_lang_Thread::priority(thr_oop); 2971 assert(MinPriority <= priority && priority <= MaxPriority, "sanity check"); 2972 return priority; 2973 } 2974 2975 void JavaThread::prepare(jobject jni_thread, ThreadPriority prio) { 2976 2977 assert(Threads_lock->owner() == Thread::current(), "must have threads lock"); 2978 // Link Java Thread object <-> C++ Thread 2979 2980 // Get the C++ thread object (an oop) from the JNI handle (a jthread) 3286 // considering that WatchThread terminates when the VM is on the way to 3287 // exit at safepoint, the chance of the above is extremely small. The right 3288 // way to prevent termination of WatcherThread would be to acquire 3289 // Terminator_lock, but we can't do that without violating the lock rank 3290 // checking in some cases. 3291 if (wt != NULL) { 3292 tc->do_thread(wt); 3293 } 3294 3295 // If CompilerThreads ever become non-JavaThreads, add them here 3296 } 3297 3298 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) { 3299 TraceTime timer("Initialize java.lang classes", TraceStartupTime); 3300 3301 if (EagerXrunInit && Arguments::init_libraries_at_startup()) { 3302 create_vm_init_libraries(); 3303 } 3304 3305 initialize_class(vmSymbols::java_lang_String(), CHECK); 3306 3307 // Initialize java_lang.System (needed before creating the thread) 3308 initialize_class(vmSymbols::java_lang_System(), CHECK); 3309 // The VM creates & returns objects of this class. Make sure it's initialized. 3310 initialize_class(vmSymbols::java_lang_Class(), CHECK); 3311 initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK); 3312 Handle thread_group = create_initial_thread_group(CHECK); 3313 Universe::set_main_thread_group(thread_group()); 3314 initialize_class(vmSymbols::java_lang_Thread(), CHECK); 3315 oop thread_object = create_initial_thread(thread_group, main_thread, CHECK); 3316 main_thread->set_threadObj(thread_object); 3317 // Set thread status to running since main thread has 3318 // been started and running. 3319 java_lang_Thread::set_thread_status(thread_object, 3320 java_lang_Thread::RUNNABLE); 3321 3322 // The VM preresolves methods to these classes. Make sure that they get initialized 3323 initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK); 3324 initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK); 3325 call_initializeSystemClass(CHECK); | 2916 } 2917 } else if (is_attaching_via_jni()) { // workaround for 6412693 - see 6404306 2918 name_str = "<no-name - thread is attaching>"; 2919 } else { 2920 name_str = Thread::name(); 2921 } 2922 } else { 2923 name_str = Thread::name(); 2924 } 2925 assert(name_str != NULL, "unexpected NULL thread name"); 2926 return name_str; 2927 } 2928 2929 2930 const char* JavaThread::get_threadgroup_name() const { 2931 debug_only(if (JavaThread::current() != this) assert_locked_or_safepoint(Threads_lock);) 2932 oop thread_obj = threadObj(); 2933 if (thread_obj != NULL) { 2934 oop thread_group = java_lang_Thread::threadGroup(thread_obj); 2935 if (thread_group != NULL) { 2936 // ThreadGroup.name can be null 2937 return java_lang_ThreadGroup::name(thread_group); 2938 } 2939 } 2940 return NULL; 2941 } 2942 2943 const char* JavaThread::get_parent_name() const { 2944 debug_only(if (JavaThread::current() != this) assert_locked_or_safepoint(Threads_lock);) 2945 oop thread_obj = threadObj(); 2946 if (thread_obj != NULL) { 2947 oop thread_group = java_lang_Thread::threadGroup(thread_obj); 2948 if (thread_group != NULL) { 2949 oop parent = java_lang_ThreadGroup::parent(thread_group); 2950 if (parent != NULL) { 2951 // ThreadGroup.name can be null 2952 return java_lang_ThreadGroup::name(parent); 2953 } 2954 } 2955 } 2956 return NULL; 2957 } 2958 2959 ThreadPriority JavaThread::java_priority() const { 2960 oop thr_oop = threadObj(); 2961 if (thr_oop == NULL) return NormPriority; // Bootstrapping 2962 ThreadPriority priority = java_lang_Thread::priority(thr_oop); 2963 assert(MinPriority <= priority && priority <= MaxPriority, "sanity check"); 2964 return priority; 2965 } 2966 2967 void JavaThread::prepare(jobject jni_thread, ThreadPriority prio) { 2968 2969 assert(Threads_lock->owner() == Thread::current(), "must have threads lock"); 2970 // Link Java Thread object <-> C++ Thread 2971 2972 // Get the C++ thread object (an oop) from the JNI handle (a jthread) 3278 // considering that WatchThread terminates when the VM is on the way to 3279 // exit at safepoint, the chance of the above is extremely small. The right 3280 // way to prevent termination of WatcherThread would be to acquire 3281 // Terminator_lock, but we can't do that without violating the lock rank 3282 // checking in some cases. 3283 if (wt != NULL) { 3284 tc->do_thread(wt); 3285 } 3286 3287 // If CompilerThreads ever become non-JavaThreads, add them here 3288 } 3289 3290 void Threads::initialize_java_lang_classes(JavaThread* main_thread, TRAPS) { 3291 TraceTime timer("Initialize java.lang classes", TraceStartupTime); 3292 3293 if (EagerXrunInit && Arguments::init_libraries_at_startup()) { 3294 create_vm_init_libraries(); 3295 } 3296 3297 initialize_class(vmSymbols::java_lang_String(), CHECK); 3298 3299 // Inject CompactStrings value after the static initializers for String ran. 3300 java_lang_String::set_compact_strings(CompactStrings); 3301 3302 // Initialize java_lang.System (needed before creating the thread) 3303 initialize_class(vmSymbols::java_lang_System(), CHECK); 3304 // The VM creates & returns objects of this class. Make sure it's initialized. 3305 initialize_class(vmSymbols::java_lang_Class(), CHECK); 3306 initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK); 3307 Handle thread_group = create_initial_thread_group(CHECK); 3308 Universe::set_main_thread_group(thread_group()); 3309 initialize_class(vmSymbols::java_lang_Thread(), CHECK); 3310 oop thread_object = create_initial_thread(thread_group, main_thread, CHECK); 3311 main_thread->set_threadObj(thread_object); 3312 // Set thread status to running since main thread has 3313 // been started and running. 3314 java_lang_Thread::set_thread_status(thread_object, 3315 java_lang_Thread::RUNNABLE); 3316 3317 // The VM preresolves methods to these classes. Make sure that they get initialized 3318 initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK); 3319 initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK); 3320 call_initializeSystemClass(CHECK); |