402 // dynamically computed constant uses wrap_dynamic_exception for:
403 // - bootstrap method resolution
404 // - post call to MethodHandleNatives::linkDynamicConstant
405 void Exceptions::wrap_dynamic_exception(Thread* THREAD) {
406 if (THREAD->has_pending_exception()) {
407 oop exception = THREAD->pending_exception();
408 // See the "Linking Exceptions" section for the invokedynamic instruction
409 // in JVMS 6.5.
410 if (exception->is_a(SystemDictionary::Error_klass())) {
411 // Pass through an Error, including BootstrapMethodError, any other form
412 // of linkage error, or say ThreadDeath/OutOfMemoryError
413 if (TraceMethodHandles) {
414 tty->print_cr("[constant/invoke]dynamic passes through an Error for " INTPTR_FORMAT, p2i((void *)exception));
415 exception->print();
416 }
417 return;
418 }
419
420 // Otherwise wrap the exception in a BootstrapMethodError
421 if (TraceMethodHandles) {
422 tty->print_cr("[constant/invoke]dynamic throws BSME for " INTPTR_FORMAT, p2i((void *)exception));
423 exception->print();
424 }
425 Handle nested_exception(THREAD, exception);
426 THREAD->clear_pending_exception();
427 THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception)
428 }
429 }
430
431 // Exception counting for hs_err file
432 volatile int Exceptions::_stack_overflow_errors = 0;
433 volatile int Exceptions::_linkage_errors = 0;
434 volatile int Exceptions::_out_of_memory_error_java_heap_errors = 0;
435 volatile int Exceptions::_out_of_memory_error_metaspace_errors = 0;
436 volatile int Exceptions::_out_of_memory_error_class_metaspace_errors = 0;
437
438 void Exceptions::count_out_of_memory_exceptions(Handle exception) {
439 if (oopDesc::equals(exception(), Universe::out_of_memory_error_metaspace())) {
440 Atomic::inc(&_out_of_memory_error_metaspace_errors);
441 } else if (oopDesc::equals(exception(), Universe::out_of_memory_error_class_metaspace())) {
442 Atomic::inc(&_out_of_memory_error_class_metaspace_errors);
|
402 // dynamically computed constant uses wrap_dynamic_exception for:
403 // - bootstrap method resolution
404 // - post call to MethodHandleNatives::linkDynamicConstant
405 void Exceptions::wrap_dynamic_exception(Thread* THREAD) {
406 if (THREAD->has_pending_exception()) {
407 oop exception = THREAD->pending_exception();
408 // See the "Linking Exceptions" section for the invokedynamic instruction
409 // in JVMS 6.5.
410 if (exception->is_a(SystemDictionary::Error_klass())) {
411 // Pass through an Error, including BootstrapMethodError, any other form
412 // of linkage error, or say ThreadDeath/OutOfMemoryError
413 if (TraceMethodHandles) {
414 tty->print_cr("[constant/invoke]dynamic passes through an Error for " INTPTR_FORMAT, p2i((void *)exception));
415 exception->print();
416 }
417 return;
418 }
419
420 // Otherwise wrap the exception in a BootstrapMethodError
421 if (TraceMethodHandles) {
422 tty->print_cr("bootstrap method invocation wraps BSME around " INTPTR_FORMAT, p2i((void *)exception));
423 exception->print();
424 }
425 Handle nested_exception(THREAD, exception);
426 THREAD->clear_pending_exception();
427 THROW_CAUSE(vmSymbols::java_lang_BootstrapMethodError(), nested_exception)
428 }
429 }
430
431 // Exception counting for hs_err file
432 volatile int Exceptions::_stack_overflow_errors = 0;
433 volatile int Exceptions::_linkage_errors = 0;
434 volatile int Exceptions::_out_of_memory_error_java_heap_errors = 0;
435 volatile int Exceptions::_out_of_memory_error_metaspace_errors = 0;
436 volatile int Exceptions::_out_of_memory_error_class_metaspace_errors = 0;
437
438 void Exceptions::count_out_of_memory_exceptions(Handle exception) {
439 if (oopDesc::equals(exception(), Universe::out_of_memory_error_metaspace())) {
440 Atomic::inc(&_out_of_memory_error_metaspace_errors);
441 } else if (oopDesc::equals(exception(), Universe::out_of_memory_error_class_metaspace())) {
442 Atomic::inc(&_out_of_memory_error_class_metaspace_errors);
|