hotspot/src/share/vm/runtime/thread.cpp
changeset 25057 f38210f84f8c
parent 24849 20b9d8928c43
child 25058 4542f853c2ac
equal deleted inserted replaced
25056:5ad92b0d1beb 25057:f38210f84f8c
  1736   {
  1736   {
  1737     EXCEPTION_MARK;
  1737     EXCEPTION_MARK;
  1738 
  1738 
  1739     CLEAR_PENDING_EXCEPTION;
  1739     CLEAR_PENDING_EXCEPTION;
  1740   }
  1740   }
  1741   // FIXIT: The is_null check is only so it works better on JDK1.2 VM's. This
  1741   if (!destroy_vm) {
  1742   // has to be fixed by a runtime query method
       
  1743   if (!destroy_vm || JDK_Version::is_jdk12x_version()) {
       
  1744     // JSR-166: change call from from ThreadGroup.uncaughtException to
       
  1745     // java.lang.Thread.dispatchUncaughtException
       
  1746     if (uncaught_exception.not_null()) {
  1742     if (uncaught_exception.not_null()) {
  1747       Handle group(this, java_lang_Thread::threadGroup(threadObj()));
  1743       EXCEPTION_MARK;
  1748       {
  1744       // Call method Thread.dispatchUncaughtException().
  1749         EXCEPTION_MARK;
  1745       KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
  1750         // Check if the method Thread.dispatchUncaughtException() exists. If so
  1746       JavaValue result(T_VOID);
  1751         // call it.  Otherwise we have an older library without the JSR-166 changes,
  1747       JavaCalls::call_virtual(&result,
  1752         // so call ThreadGroup.uncaughtException()
  1748                               threadObj, thread_klass,
  1753         KlassHandle recvrKlass(THREAD, threadObj->klass());
  1749                               vmSymbols::dispatchUncaughtException_name(),
  1754         CallInfo callinfo;
  1750                               vmSymbols::throwable_void_signature(),
  1755         KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
  1751                               uncaught_exception,
  1756         LinkResolver::resolve_virtual_call(callinfo, threadObj, recvrKlass, thread_klass,
  1752                               THREAD);
  1757                                            vmSymbols::dispatchUncaughtException_name(),
  1753       if (HAS_PENDING_EXCEPTION) {
  1758                                            vmSymbols::throwable_void_signature(),
  1754         ResourceMark rm(this);
  1759                                            KlassHandle(), false, false, THREAD);
  1755         jio_fprintf(defaultStream::error_stream(),
       
  1756               "\nException: %s thrown from the UncaughtExceptionHandler"
       
  1757               " in thread \"%s\"\n",
       
  1758               pending_exception()->klass()->external_name(),
       
  1759               get_thread_name());
  1760         CLEAR_PENDING_EXCEPTION;
  1760         CLEAR_PENDING_EXCEPTION;
  1761         methodHandle method = callinfo.selected_method();
       
  1762         if (method.not_null()) {
       
  1763           JavaValue result(T_VOID);
       
  1764           JavaCalls::call_virtual(&result,
       
  1765                                   threadObj, thread_klass,
       
  1766                                   vmSymbols::dispatchUncaughtException_name(),
       
  1767                                   vmSymbols::throwable_void_signature(),
       
  1768                                   uncaught_exception,
       
  1769                                   THREAD);
       
  1770         } else {
       
  1771           KlassHandle thread_group(THREAD, SystemDictionary::ThreadGroup_klass());
       
  1772           JavaValue result(T_VOID);
       
  1773           JavaCalls::call_virtual(&result,
       
  1774                                   group, thread_group,
       
  1775                                   vmSymbols::uncaughtException_name(),
       
  1776                                   vmSymbols::thread_throwable_void_signature(),
       
  1777                                   threadObj,           // Arg 1
       
  1778                                   uncaught_exception,  // Arg 2
       
  1779                                   THREAD);
       
  1780         }
       
  1781         if (HAS_PENDING_EXCEPTION) {
       
  1782           ResourceMark rm(this);
       
  1783           jio_fprintf(defaultStream::error_stream(),
       
  1784                 "\nException: %s thrown from the UncaughtExceptionHandler"
       
  1785                 " in thread \"%s\"\n",
       
  1786                 pending_exception()->klass()->external_name(),
       
  1787                 get_thread_name());
       
  1788           CLEAR_PENDING_EXCEPTION;
       
  1789         }
       
  1790       }
  1761       }
  1791     }
  1762     }
  1792 
  1763 
  1793     // Called before the java thread exit since we want to read info
  1764     // Called before the java thread exit since we want to read info
  1794     // from java_lang_Thread object
  1765     // from java_lang_Thread object
  2846     st->print("prio=%d ", java_lang_Thread::priority(thread_oop));
  2817     st->print("prio=%d ", java_lang_Thread::priority(thread_oop));
  2847   }
  2818   }
  2848   Thread::print_on(st);
  2819   Thread::print_on(st);
  2849   // print guess for valid stack memory region (assume 4K pages); helps lock debugging
  2820   // print guess for valid stack memory region (assume 4K pages); helps lock debugging
  2850   st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12));
  2821   st->print_cr("[" INTPTR_FORMAT "]", (intptr_t)last_Java_sp() & ~right_n_bits(12));
  2851   if (thread_oop != NULL && JDK_Version::is_gte_jdk15x_version()) {
  2822   if (thread_oop != NULL) {
  2852     st->print_cr("   java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop));
  2823     st->print_cr("   java.lang.Thread.State: %s", java_lang_Thread::thread_status_name(thread_oop));
  2853   }
  2824   }
  2854 #ifndef PRODUCT
  2825 #ifndef PRODUCT
  2855   print_thread_state_on(st);
  2826   print_thread_state_on(st);
  2856   _safepoint_state->print_on(st);
  2827   _safepoint_state->print_on(st);
  3946   if (ShowMessageBoxOnError && is_error_reported()) {
  3917   if (ShowMessageBoxOnError && is_error_reported()) {
  3947     os::infinite_sleep();
  3918     os::infinite_sleep();
  3948   }
  3919   }
  3949   os::wait_for_keypress_at_exit();
  3920   os::wait_for_keypress_at_exit();
  3950 
  3921 
  3951   if (JDK_Version::is_jdk12x_version()) {
  3922   // run Java level shutdown hooks
  3952     // We are the last thread running, so check if finalizers should be run.
  3923   thread->invoke_shutdown_hooks();
  3953     // For 1.3 or later this is done in thread->invoke_shutdown_hooks()
       
  3954     HandleMark rm(thread);
       
  3955     Universe::run_finalizers_on_exit();
       
  3956   } else {
       
  3957     // run Java level shutdown hooks
       
  3958     thread->invoke_shutdown_hooks();
       
  3959   }
       
  3960 
  3924 
  3961   before_exit(thread);
  3925   before_exit(thread);
  3962 
  3926 
  3963   thread->exit(true);
  3927   thread->exit(true);
  3964 
  3928