1714 |
1714 |
1715 // For any new cleanup additions, please check to see if they need to be applied to |
1715 // For any new cleanup additions, please check to see if they need to be applied to |
1716 // cleanup_failed_attach_current_thread as well. |
1716 // cleanup_failed_attach_current_thread as well. |
1717 void JavaThread::exit(bool destroy_vm, ExitType exit_type) { |
1717 void JavaThread::exit(bool destroy_vm, ExitType exit_type) { |
1718 assert(this == JavaThread::current(), "thread consistency check"); |
1718 assert(this == JavaThread::current(), "thread consistency check"); |
1719 if (!InitializeJavaLangSystem) return; |
|
1720 |
1719 |
1721 HandleMark hm(this); |
1720 HandleMark hm(this); |
1722 Handle uncaught_exception(this, this->pending_exception()); |
1721 Handle uncaught_exception(this, this->pending_exception()); |
1723 this->clear_pending_exception(); |
1722 this->clear_pending_exception(); |
1724 Handle threadObj(this, this->threadObj()); |
1723 Handle threadObj(this, this->threadObj()); |
3512 } |
3507 } |
3513 } |
3508 } |
3514 } |
3509 } |
3515 |
3510 |
3516 // Initialize java_lang.System (needed before creating the thread) |
3511 // Initialize java_lang.System (needed before creating the thread) |
3517 if (InitializeJavaLangSystem) { |
3512 initialize_class(vmSymbols::java_lang_System(), CHECK_0); |
3518 initialize_class(vmSymbols::java_lang_System(), CHECK_0); |
3513 initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK_0); |
3519 initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK_0); |
3514 Handle thread_group = create_initial_thread_group(CHECK_0); |
3520 Handle thread_group = create_initial_thread_group(CHECK_0); |
3515 Universe::set_main_thread_group(thread_group()); |
3521 Universe::set_main_thread_group(thread_group()); |
3516 initialize_class(vmSymbols::java_lang_Thread(), CHECK_0); |
3522 initialize_class(vmSymbols::java_lang_Thread(), CHECK_0); |
3517 oop thread_object = create_initial_thread(thread_group, main_thread, CHECK_0); |
3523 oop thread_object = create_initial_thread(thread_group, main_thread, CHECK_0); |
3518 main_thread->set_threadObj(thread_object); |
3524 main_thread->set_threadObj(thread_object); |
3519 // Set thread status to running since main thread has |
3525 // Set thread status to running since main thread has |
3520 // been started and running. |
3526 // been started and running. |
3521 java_lang_Thread::set_thread_status(thread_object, |
3527 java_lang_Thread::set_thread_status(thread_object, |
3522 java_lang_Thread::RUNNABLE); |
3528 java_lang_Thread::RUNNABLE); |
3523 |
3529 |
3524 // The VM creates & returns objects of this class. Make sure it's initialized. |
3530 // The VM creates & returns objects of this class. Make sure it's initialized. |
3525 initialize_class(vmSymbols::java_lang_Class(), CHECK_0); |
3531 initialize_class(vmSymbols::java_lang_Class(), CHECK_0); |
3526 |
3532 |
3527 // The VM preresolves methods to these classes. Make sure that they get initialized |
3533 // The VM preresolves methods to these classes. Make sure that they get initialized |
3528 initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK_0); |
3534 initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK_0); |
3529 initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK_0); |
3535 initialize_class(vmSymbols::java_lang_ref_Finalizer(), CHECK_0); |
3530 call_initializeSystemClass(CHECK_0); |
3536 call_initializeSystemClass(CHECK_0); |
3531 |
3537 |
3532 // get the Java runtime name after java.lang.System is initialized |
3538 // get the Java runtime name after java.lang.System is initialized |
3533 JDK_Version::set_runtime_name(get_java_runtime_name(THREAD)); |
3539 JDK_Version::set_runtime_name(get_java_runtime_name(THREAD)); |
3534 JDK_Version::set_runtime_version(get_java_runtime_version(THREAD)); |
3540 JDK_Version::set_runtime_version(get_java_runtime_version(THREAD)); |
|
3541 } else { |
|
3542 warning("java.lang.System not initialized"); |
|
3543 } |
|
3544 |
3535 |
3545 // an instance of OutOfMemory exception has been allocated earlier |
3536 // an instance of OutOfMemory exception has been allocated earlier |
3546 if (InitializeJavaLangExceptionsErrors) { |
3537 initialize_class(vmSymbols::java_lang_OutOfMemoryError(), CHECK_0); |
3547 initialize_class(vmSymbols::java_lang_OutOfMemoryError(), CHECK_0); |
3538 initialize_class(vmSymbols::java_lang_NullPointerException(), CHECK_0); |
3548 initialize_class(vmSymbols::java_lang_NullPointerException(), CHECK_0); |
3539 initialize_class(vmSymbols::java_lang_ClassCastException(), CHECK_0); |
3549 initialize_class(vmSymbols::java_lang_ClassCastException(), CHECK_0); |
3540 initialize_class(vmSymbols::java_lang_ArrayStoreException(), CHECK_0); |
3550 initialize_class(vmSymbols::java_lang_ArrayStoreException(), CHECK_0); |
3541 initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK_0); |
3551 initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK_0); |
3542 initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK_0); |
3552 initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK_0); |
3543 initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK_0); |
3553 initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK_0); |
3544 initialize_class(vmSymbols::java_lang_IllegalArgumentException(), CHECK_0); |
3554 initialize_class(vmSymbols::java_lang_IllegalArgumentException(), CHECK_0); |
|
3555 } else { |
|
3556 warning("java.lang.OutOfMemoryError has not been initialized"); |
|
3557 warning("java.lang.NullPointerException has not been initialized"); |
|
3558 warning("java.lang.ClassCastException has not been initialized"); |
|
3559 warning("java.lang.ArrayStoreException has not been initialized"); |
|
3560 warning("java.lang.ArithmeticException has not been initialized"); |
|
3561 warning("java.lang.StackOverflowError has not been initialized"); |
|
3562 warning("java.lang.IllegalArgumentException has not been initialized"); |
|
3563 } |
|
3564 } |
3545 } |
3565 |
3546 |
3566 // See : bugid 4211085. |
3547 // See : bugid 4211085. |
3567 // Background : the static initializer of java.lang.Compiler tries to read |
3548 // Background : the static initializer of java.lang.Compiler tries to read |
3568 // property"java.compiler" and read & write property "java.vm.info". |
3549 // property"java.compiler" and read & write property "java.vm.info". |