164 Symbol* signature, JavaCallArguments* args,
165 Handle cause,
166 Handle loader);
167
168 static Handle new_exception(JavaThread* thread, Symbol* name,
169 Handle cause,
170 Handle loader,
171 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8);
172
173 static Handle new_exception(JavaThread* thread, Symbol* name,
174 const char* message, Handle cause,
175 Handle loader,
176 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8);
177
178 static Handle new_exception(JavaThread* thread, Symbol* name,
179 const char* message,
180 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8);
181
182 static void throw_stack_overflow_exception(JavaThread* thread, const char* file, int line, const methodHandle& method);
183
184 static void wrap_dynamic_exception(bool is_indy, JavaThread* thread);
185
186 // Exception counting of interesting exceptions that may have caused a
187 // problem for the JVM, for reporting in the hs_err file.
188 static void increment_stack_overflow_errors();
189 static bool has_exception_counts();
190 static void count_out_of_memory_exceptions(Handle exception);
191 static void print_exception_counts_on_error(outputStream* st);
192
193 // for AbortVMOnException flag
194 static void debug_check_abort(Handle exception, const char* message = nullptr);
195 static void debug_check_abort_helper(Handle exception, const char* message = nullptr);
196 static void debug_check_abort(const char *value_string, const char* message = nullptr);
197
198 // for logging exceptions
199 static void log_exception(Handle exception, const char* message);
200 static void log_exception_stacktrace(Handle exception);
201 static void log_exception_stacktrace(Handle exception, methodHandle method, int bci);
202 };
203
250
251 // CAUTION: These macros clears all exceptions except probable async exceptions j.l.InternalError.
252 // So use it with caution.
253 #define CLEAR_PENDING_NONASYNC_EXCEPTION (((ThreadShadow*)THREAD)->clear_pending_nonasync_exception())
254 #define CHECK_AND_CLEAR_NONASYNC THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_NONASYNC_EXCEPTION; return; } (void)(0
255 #define CHECK_AND_CLEAR_NONASYNC_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_NONASYNC_EXCEPTION; return result; } (void)(0
256 #define CHECK_AND_CLEAR_NONASYNC_0 CHECK_AND_CLEAR_NONASYNC_(0)
257 #define CHECK_AND_CLEAR_NONASYNC_NH CHECK_AND_CLEAR_NONASYNC_(Handle())
258 #define CHECK_AND_CLEAR_NONASYNC_NULL CHECK_AND_CLEAR_NONASYNC_(nullptr)
259 #define CHECK_AND_CLEAR_NONASYNC_false CHECK_AND_CLEAR_NONASYNC_(false)
260
261 #define CLEAR_PENDING_PREEMPTED_EXCEPTION (((ThreadShadow*)THREAD)->clear_pending_preempted_exception())
262 #define CHECK_AND_CLEAR_PREEMPTED THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_PREEMPTED_EXCEPTION; return; } (void)(0
263
264
265 // The THROW... macros should be used to throw an exception. They require a THREAD variable to be
266 // visible within the scope containing the THROW. Usually this is achieved by declaring the function
267 // with a TRAPS argument.
268
269 #define THREAD_AND_LOCATION THREAD, __FILE__, __LINE__
270
271 #define THROW_OOP(e) \
272 { Exceptions::_throw_oop(THREAD_AND_LOCATION, e); return; }
273
274 #define THROW_HANDLE(e) \
275 { Exceptions::_throw(THREAD_AND_LOCATION, e); return; }
276
277 #define THROW(name) \
278 { Exceptions::_throw_msg(THREAD_AND_LOCATION, name, nullptr); return; }
279
280 #define THROW_MSG(name, message) \
281 { Exceptions::_throw_msg(THREAD_AND_LOCATION, name, message); return; }
282
283 #define THROW_CAUSE(name, cause) \
284 { Exceptions::_throw_cause(THREAD_AND_LOCATION, name, cause); return; }
285
286 #define THROW_MSG_LOADER(name, message, loader) \
287 { Exceptions::_throw_msg(THREAD_AND_LOCATION, name, message, loader); return; }
288
289 #define THROW_ARG(name, signature, args) \
|
164 Symbol* signature, JavaCallArguments* args,
165 Handle cause,
166 Handle loader);
167
168 static Handle new_exception(JavaThread* thread, Symbol* name,
169 Handle cause,
170 Handle loader,
171 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8);
172
173 static Handle new_exception(JavaThread* thread, Symbol* name,
174 const char* message, Handle cause,
175 Handle loader,
176 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8);
177
178 static Handle new_exception(JavaThread* thread, Symbol* name,
179 const char* message,
180 ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8);
181
182 static void throw_stack_overflow_exception(JavaThread* thread, const char* file, int line, const methodHandle& method);
183
184 static void wrap_exception_in_internal_error(const char* message, JavaThread* thread);
185
186 static void wrap_dynamic_exception(bool is_indy, JavaThread* thread);
187
188 // Exception counting of interesting exceptions that may have caused a
189 // problem for the JVM, for reporting in the hs_err file.
190 static void increment_stack_overflow_errors();
191 static bool has_exception_counts();
192 static void count_out_of_memory_exceptions(Handle exception);
193 static void print_exception_counts_on_error(outputStream* st);
194
195 // for AbortVMOnException flag
196 static void debug_check_abort(Handle exception, const char* message = nullptr);
197 static void debug_check_abort_helper(Handle exception, const char* message = nullptr);
198 static void debug_check_abort(const char *value_string, const char* message = nullptr);
199
200 // for logging exceptions
201 static void log_exception(Handle exception, const char* message);
202 static void log_exception_stacktrace(Handle exception);
203 static void log_exception_stacktrace(Handle exception, methodHandle method, int bci);
204 };
205
252
253 // CAUTION: These macros clears all exceptions except probable async exceptions j.l.InternalError.
254 // So use it with caution.
255 #define CLEAR_PENDING_NONASYNC_EXCEPTION (((ThreadShadow*)THREAD)->clear_pending_nonasync_exception())
256 #define CHECK_AND_CLEAR_NONASYNC THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_NONASYNC_EXCEPTION; return; } (void)(0
257 #define CHECK_AND_CLEAR_NONASYNC_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_NONASYNC_EXCEPTION; return result; } (void)(0
258 #define CHECK_AND_CLEAR_NONASYNC_0 CHECK_AND_CLEAR_NONASYNC_(0)
259 #define CHECK_AND_CLEAR_NONASYNC_NH CHECK_AND_CLEAR_NONASYNC_(Handle())
260 #define CHECK_AND_CLEAR_NONASYNC_NULL CHECK_AND_CLEAR_NONASYNC_(nullptr)
261 #define CHECK_AND_CLEAR_NONASYNC_false CHECK_AND_CLEAR_NONASYNC_(false)
262
263 #define CLEAR_PENDING_PREEMPTED_EXCEPTION (((ThreadShadow*)THREAD)->clear_pending_preempted_exception())
264 #define CHECK_AND_CLEAR_PREEMPTED THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_PREEMPTED_EXCEPTION; return; } (void)(0
265
266
267 // The THROW... macros should be used to throw an exception. They require a THREAD variable to be
268 // visible within the scope containing the THROW. Usually this is achieved by declaring the function
269 // with a TRAPS argument.
270
271 #define THREAD_AND_LOCATION THREAD, __FILE__, __LINE__
272 #define THREAD_AND_LOCATION_DECL TRAPS, const char* file, int line
273 #define THREAD_AND_LOCATION_ARGS THREAD, file, line
274
275 #define THROW_OOP(e) \
276 { Exceptions::_throw_oop(THREAD_AND_LOCATION, e); return; }
277
278 #define THROW_HANDLE(e) \
279 { Exceptions::_throw(THREAD_AND_LOCATION, e); return; }
280
281 #define THROW(name) \
282 { Exceptions::_throw_msg(THREAD_AND_LOCATION, name, nullptr); return; }
283
284 #define THROW_MSG(name, message) \
285 { Exceptions::_throw_msg(THREAD_AND_LOCATION, name, message); return; }
286
287 #define THROW_CAUSE(name, cause) \
288 { Exceptions::_throw_cause(THREAD_AND_LOCATION, name, cause); return; }
289
290 #define THROW_MSG_LOADER(name, message, loader) \
291 { Exceptions::_throw_msg(THREAD_AND_LOCATION, name, message, loader); return; }
292
293 #define THROW_ARG(name, signature, args) \
|