85 86 // use THROW whenever possible! 87 void set_pending_exception(oop exception, const char* file, int line); 88 89 // use CLEAR_PENDING_EXCEPTION whenever possible! 90 void clear_pending_exception(); 91 92 ThreadShadow() : _pending_exception(NULL), 93 _exception_file(NULL), _exception_line(0) {} 94 }; 95 96 97 // Exceptions is a helper class that encapsulates all operations 98 // that require access to the thread interface and which are 99 // relatively rare. The Exceptions operations should only be 100 // used directly if the macros below are insufficient. 101 102 class Exceptions { 103 static bool special_exception(Thread *thread, const char* file, int line, Handle exception); 104 static bool special_exception(Thread* thread, const char* file, int line, Symbol* name, const char* message); 105 public: 106 // this enum is defined to indicate whether it is safe to 107 // ignore the encoding scheme of the original message string. 108 typedef enum { 109 safe_to_utf8 = 0, 110 unsafe_to_utf8 = 1 111 } ExceptionMsgToUtf8Mode; 112 // Throw exceptions: w/o message, w/ message & with formatted message. 113 static void _throw_oop(Thread* thread, const char* file, int line, oop exception); 114 static void _throw(Thread* thread, const char* file, int line, Handle exception, const char* msg = NULL); 115 116 static void _throw_msg(Thread* thread, const char* file, int line, Symbol* name, const char* message); 117 static void _throw_msg(Thread* thread, const char* file, int line, Symbol* name, const char* message, 118 Handle loader, Handle protection_domain); 119 120 static void _throw_msg_cause(Thread* thread, const char* file, int line, Symbol* name, const char* message, Handle h_cause); 121 static void _throw_msg_cause(Thread* thread, const char* file, int line, Symbol* name, const char* message, Handle h_cause, 122 Handle h_loader, Handle h_protection_domain); 123 124 static void _throw_cause(Thread* thread, const char* file, int line, Symbol* name, Handle h_cause); 142 static Handle new_exception(Thread* thread, Symbol* name, 143 Symbol* signature, JavaCallArguments* args, 144 Handle cause, 145 Handle loader, Handle protection_domain); 146 147 static Handle new_exception(Thread* thread, Symbol* name, 148 Handle cause, 149 Handle loader, Handle protection_domain, 150 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8); 151 152 static Handle new_exception(Thread* thread, Symbol* name, 153 const char* message, Handle cause, 154 Handle loader, Handle protection_domain, 155 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8); 156 157 static Handle new_exception(Thread* thread, Symbol* name, 158 const char* message, 159 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8); 160 161 static void throw_stack_overflow_exception(Thread* thread, const char* file, int line, methodHandle method); 162 163 // for AbortVMOnException flag 164 NOT_PRODUCT(static void debug_check_abort(Handle exception, const char* message = NULL);) 165 NOT_PRODUCT(static void debug_check_abort(const char *value_string, const char* message = NULL);) 166 }; 167 168 169 // The THREAD & TRAPS macros facilitate the declaration of functions that throw exceptions. 170 // Convention: Use the TRAPS macro as the last argument of such a function; e.g.: 171 // 172 // int this_function_may_trap(int x, float y, TRAPS) 173 174 #define THREAD __the_thread__ 175 #define TRAPS Thread* THREAD 176 177 178 // The CHECK... macros should be used to pass along a THREAD reference and to check for pending 179 // exceptions. In special situations it is necessary to handle pending exceptions explicitly, 180 // in these cases the PENDING_EXCEPTION helper macros should be used. 181 // | 85 86 // use THROW whenever possible! 87 void set_pending_exception(oop exception, const char* file, int line); 88 89 // use CLEAR_PENDING_EXCEPTION whenever possible! 90 void clear_pending_exception(); 91 92 ThreadShadow() : _pending_exception(NULL), 93 _exception_file(NULL), _exception_line(0) {} 94 }; 95 96 97 // Exceptions is a helper class that encapsulates all operations 98 // that require access to the thread interface and which are 99 // relatively rare. The Exceptions operations should only be 100 // used directly if the macros below are insufficient. 101 102 class Exceptions { 103 static bool special_exception(Thread *thread, const char* file, int line, Handle exception); 104 static bool special_exception(Thread* thread, const char* file, int line, Symbol* name, const char* message); 105 106 // Count out of memory errors that are interesting in error diagnosis 107 static volatile int _out_of_memory_error_java_heap_errors; 108 static volatile int _out_of_memory_error_metaspace_errors; 109 static volatile int _out_of_memory_error_class_metaspace_errors; 110 public: 111 // this enum is defined to indicate whether it is safe to 112 // ignore the encoding scheme of the original message string. 113 typedef enum { 114 safe_to_utf8 = 0, 115 unsafe_to_utf8 = 1 116 } ExceptionMsgToUtf8Mode; 117 // Throw exceptions: w/o message, w/ message & with formatted message. 118 static void _throw_oop(Thread* thread, const char* file, int line, oop exception); 119 static void _throw(Thread* thread, const char* file, int line, Handle exception, const char* msg = NULL); 120 121 static void _throw_msg(Thread* thread, const char* file, int line, Symbol* name, const char* message); 122 static void _throw_msg(Thread* thread, const char* file, int line, Symbol* name, const char* message, 123 Handle loader, Handle protection_domain); 124 125 static void _throw_msg_cause(Thread* thread, const char* file, int line, Symbol* name, const char* message, Handle h_cause); 126 static void _throw_msg_cause(Thread* thread, const char* file, int line, Symbol* name, const char* message, Handle h_cause, 127 Handle h_loader, Handle h_protection_domain); 128 129 static void _throw_cause(Thread* thread, const char* file, int line, Symbol* name, Handle h_cause); 147 static Handle new_exception(Thread* thread, Symbol* name, 148 Symbol* signature, JavaCallArguments* args, 149 Handle cause, 150 Handle loader, Handle protection_domain); 151 152 static Handle new_exception(Thread* thread, Symbol* name, 153 Handle cause, 154 Handle loader, Handle protection_domain, 155 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8); 156 157 static Handle new_exception(Thread* thread, Symbol* name, 158 const char* message, Handle cause, 159 Handle loader, Handle protection_domain, 160 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8); 161 162 static Handle new_exception(Thread* thread, Symbol* name, 163 const char* message, 164 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8); 165 166 static void throw_stack_overflow_exception(Thread* thread, const char* file, int line, methodHandle method); 167 168 // Exception counting for error files of interesting exceptions that may have 169 // caused a problem for the jvm 170 static volatile int _stack_overflow_errors; 171 172 static bool has_exception_counts(); 173 static void count_out_of_memory_exceptions(Handle exception); 174 static void print_exception_counts_on_error(outputStream* st); 175 176 // for AbortVMOnException flag 177 NOT_PRODUCT(static void debug_check_abort(Handle exception, const char* message = NULL);) 178 NOT_PRODUCT(static void debug_check_abort(const char *value_string, const char* message = NULL);) 179 }; 180 181 182 // The THREAD & TRAPS macros facilitate the declaration of functions that throw exceptions. 183 // Convention: Use the TRAPS macro as the last argument of such a function; e.g.: 184 // 185 // int this_function_may_trap(int x, float y, TRAPS) 186 187 #define THREAD __the_thread__ 188 #define TRAPS Thread* THREAD 189 190 191 // The CHECK... macros should be used to pass along a THREAD reference and to check for pending 192 // exceptions. In special situations it is necessary to handle pending exceptions explicitly, 193 // in these cases the PENDING_EXCEPTION helper macros should be used. 194 // |