458 return new_exception(thread, name, signature, &args, h_cause, h_loader);
459 }
460
461 // Another convenience method that creates handles for null class loaders and null causes.
462 // If the last parameter 'to_utf8_mode' is safe_to_utf8,
463 // it means we can safely ignore the encoding scheme of the message string and
464 // convert it directly to a java UTF8 string. Otherwise, we need to take the
465 // encoding scheme of the string into account. One thing we should do at some
466 // point is to push this flag down to class java_lang_String since other
467 // classes may need similar functionalities.
468 Handle Exceptions::new_exception(JavaThread* thread, Symbol* name,
469 const char* message,
470 ExceptionMsgToUtf8Mode to_utf8_safe) {
471
472 Handle h_loader;
473 Handle h_cause;
474 return Exceptions::new_exception(thread, name, message, h_cause, h_loader,
475 to_utf8_safe);
476 }
477
478 // invokedynamic uses wrap_dynamic_exception for:
479 // - bootstrap method resolution
480 // - post call to MethodHandleNatives::linkCallSite
481 // dynamically computed constant uses wrap_dynamic_exception for:
482 // - bootstrap method resolution
483 // - post call to MethodHandleNatives::linkDynamicConstant
484 void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) {
485 if (THREAD->has_pending_exception()) {
486 bool log_indy = log_is_enabled(Debug, methodhandles, indy) && is_indy;
487 bool log_condy = log_is_enabled(Debug, methodhandles, condy) && !is_indy;
488 LogStreamHandle(Debug, methodhandles, indy) lsh_indy;
489 LogStreamHandle(Debug, methodhandles, condy) lsh_condy;
490 LogStream* ls = nullptr;
491 if (log_indy) {
492 ls = &lsh_indy;
493 } else if (log_condy) {
494 ls = &lsh_condy;
495 }
496 oop exception = THREAD->pending_exception();
497
|
458 return new_exception(thread, name, signature, &args, h_cause, h_loader);
459 }
460
461 // Another convenience method that creates handles for null class loaders and null causes.
462 // If the last parameter 'to_utf8_mode' is safe_to_utf8,
463 // it means we can safely ignore the encoding scheme of the message string and
464 // convert it directly to a java UTF8 string. Otherwise, we need to take the
465 // encoding scheme of the string into account. One thing we should do at some
466 // point is to push this flag down to class java_lang_String since other
467 // classes may need similar functionalities.
468 Handle Exceptions::new_exception(JavaThread* thread, Symbol* name,
469 const char* message,
470 ExceptionMsgToUtf8Mode to_utf8_safe) {
471
472 Handle h_loader;
473 Handle h_cause;
474 return Exceptions::new_exception(thread, name, message, h_cause, h_loader,
475 to_utf8_safe);
476 }
477
478 void Exceptions::wrap_exception_in_internal_error(const char* message, JavaThread* THREAD) {
479 // If there is a pending exception that is not an Error, clear it and wrap it
480 // in an InternalError instead.
481 if (THREAD->has_pending_exception()) {
482 oop exception = THREAD->pending_exception();
483 if (!exception->is_a(vmClasses::Error_klass())) {
484 Handle e(THREAD, exception);
485 THREAD->clear_pending_exception();
486 THROW_MSG_CAUSE(vmSymbols::java_lang_InternalError(), message, e);
487 }
488 }
489 }
490
491 // invokedynamic uses wrap_dynamic_exception for:
492 // - bootstrap method resolution
493 // - post call to MethodHandleNatives::linkCallSite
494 // dynamically computed constant uses wrap_dynamic_exception for:
495 // - bootstrap method resolution
496 // - post call to MethodHandleNatives::linkDynamicConstant
497 void Exceptions::wrap_dynamic_exception(bool is_indy, JavaThread* THREAD) {
498 if (THREAD->has_pending_exception()) {
499 bool log_indy = log_is_enabled(Debug, methodhandles, indy) && is_indy;
500 bool log_condy = log_is_enabled(Debug, methodhandles, condy) && !is_indy;
501 LogStreamHandle(Debug, methodhandles, indy) lsh_indy;
502 LogStreamHandle(Debug, methodhandles, condy) lsh_condy;
503 LogStream* ls = nullptr;
504 if (log_indy) {
505 ls = &lsh_indy;
506 } else if (log_condy) {
507 ls = &lsh_condy;
508 }
509 oop exception = THREAD->pending_exception();
510
|