< prev index next >

hotspot/src/share/vm/utilities/exceptions.cpp

Print this page




  63   _exception_file    = NULL;
  64   _exception_line    = 0;
  65 }
  66 // Implementation of Exceptions
  67 
  68 bool Exceptions::special_exception(Thread* thread, const char* file, int line, Handle h_exception) {
  69   // bootstrapping check
  70   if (!Universe::is_fully_initialized()) {
  71    vm_exit_during_initialization(h_exception);
  72    ShouldNotReachHere();
  73   }
  74 
  75 #ifdef ASSERT
  76   // Check for trying to throw stack overflow before initialization is complete
  77   // to prevent infinite recursion trying to initialize stack overflow without
  78   // adequate stack space.
  79   // This can happen with stress testing a large value of StackShadowPages
  80   if (h_exception()->klass() == SystemDictionary::StackOverflowError_klass()) {
  81     InstanceKlass* ik = InstanceKlass::cast(h_exception->klass());
  82     assert(ik->is_initialized(),
  83            "need to increase min_stack_allowed calculation");
  84   }
  85 #endif // ASSERT
  86 
  87   if (thread->is_VM_thread()
  88       || !thread->can_call_java()
  89       || DumpSharedSpaces ) {
  90     // We do not care what kind of exception we get for the vm-thread or a thread which
  91     // is compiling.  We just install a dummy exception object
  92     //
  93     // We also cannot throw a proper exception when dumping, because we cannot run
  94     // Java bytecodes now. A dummy exception will suffice.
  95     thread->set_pending_exception(Universe::vm_exception(), file, line);
  96     return true;
  97   }
  98 
  99   return false;
 100 }
 101 
 102 bool Exceptions::special_exception(Thread* thread, const char* file, int line, Symbol* h_name, const char* message) {
 103   // bootstrapping check


 210 
 211 // Methods for default parameters.
 212 // NOTE: These must be here (and not in the header file) because of include circularities.
 213 void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, Symbol* name, const char* message, Handle h_cause) {
 214   _throw_msg_cause(thread, file, line, name, message, h_cause, Handle(thread, NULL), Handle(thread, NULL));
 215 }
 216 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, Symbol* name, const char* message) {
 217   _throw_msg(thread, file, line, name, message, Handle(thread, NULL), Handle(thread, NULL));
 218 }
 219 void Exceptions::_throw_cause(Thread* thread, const char* file, int line, Symbol* name, Handle h_cause) {
 220   _throw_cause(thread, file, line, name, h_cause, Handle(thread, NULL), Handle(thread, NULL));
 221 }
 222 
 223 
 224 void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file, int line, const methodHandle& method) {
 225   Handle exception;
 226   if (!THREAD->has_pending_exception()) {
 227     Klass* k = SystemDictionary::StackOverflowError_klass();
 228     oop e = InstanceKlass::cast(k)->allocate_instance(CHECK);
 229     exception = Handle(THREAD, e);  // fill_in_stack trace does gc
 230     assert(InstanceKlass::cast(k)->is_initialized(), "need to increase min_stack_allowed calculation");
 231     if (StackTraceInThrowable) {
 232       java_lang_Throwable::fill_in_stack_trace(exception, method());
 233     }
 234     // Increment counter for hs_err file reporting
 235     Atomic::inc(&Exceptions::_stack_overflow_errors);
 236   } else {
 237     // if prior exception, throw that one instead
 238     exception = Handle(THREAD, THREAD->pending_exception());
 239   }
 240   _throw(THREAD, file, line, exception);
 241 }
 242 
 243 void Exceptions::fthrow(Thread* thread, const char* file, int line, Symbol* h_name, const char* format, ...) {
 244   const int max_msg_size = 1024;
 245   va_list ap;
 246   va_start(ap, format);
 247   char msg[max_msg_size];
 248   vsnprintf(msg, max_msg_size, format, ap);
 249   msg[max_msg_size-1] = '\0';
 250   va_end(ap);




  63   _exception_file    = NULL;
  64   _exception_line    = 0;
  65 }
  66 // Implementation of Exceptions
  67 
  68 bool Exceptions::special_exception(Thread* thread, const char* file, int line, Handle h_exception) {
  69   // bootstrapping check
  70   if (!Universe::is_fully_initialized()) {
  71    vm_exit_during_initialization(h_exception);
  72    ShouldNotReachHere();
  73   }
  74 
  75 #ifdef ASSERT
  76   // Check for trying to throw stack overflow before initialization is complete
  77   // to prevent infinite recursion trying to initialize stack overflow without
  78   // adequate stack space.
  79   // This can happen with stress testing a large value of StackShadowPages
  80   if (h_exception()->klass() == SystemDictionary::StackOverflowError_klass()) {
  81     InstanceKlass* ik = InstanceKlass::cast(h_exception->klass());
  82     assert(ik->is_initialized(),
  83            "need to increase java_thread_min_stack_allowed calculation");
  84   }
  85 #endif // ASSERT
  86 
  87   if (thread->is_VM_thread()
  88       || !thread->can_call_java()
  89       || DumpSharedSpaces ) {
  90     // We do not care what kind of exception we get for the vm-thread or a thread which
  91     // is compiling.  We just install a dummy exception object
  92     //
  93     // We also cannot throw a proper exception when dumping, because we cannot run
  94     // Java bytecodes now. A dummy exception will suffice.
  95     thread->set_pending_exception(Universe::vm_exception(), file, line);
  96     return true;
  97   }
  98 
  99   return false;
 100 }
 101 
 102 bool Exceptions::special_exception(Thread* thread, const char* file, int line, Symbol* h_name, const char* message) {
 103   // bootstrapping check


 210 
 211 // Methods for default parameters.
 212 // NOTE: These must be here (and not in the header file) because of include circularities.
 213 void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, Symbol* name, const char* message, Handle h_cause) {
 214   _throw_msg_cause(thread, file, line, name, message, h_cause, Handle(thread, NULL), Handle(thread, NULL));
 215 }
 216 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, Symbol* name, const char* message) {
 217   _throw_msg(thread, file, line, name, message, Handle(thread, NULL), Handle(thread, NULL));
 218 }
 219 void Exceptions::_throw_cause(Thread* thread, const char* file, int line, Symbol* name, Handle h_cause) {
 220   _throw_cause(thread, file, line, name, h_cause, Handle(thread, NULL), Handle(thread, NULL));
 221 }
 222 
 223 
 224 void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file, int line, const methodHandle& method) {
 225   Handle exception;
 226   if (!THREAD->has_pending_exception()) {
 227     Klass* k = SystemDictionary::StackOverflowError_klass();
 228     oop e = InstanceKlass::cast(k)->allocate_instance(CHECK);
 229     exception = Handle(THREAD, e);  // fill_in_stack trace does gc
 230     assert(InstanceKlass::cast(k)->is_initialized(), "need to increase java_thread_min_stack_allowed calculation");
 231     if (StackTraceInThrowable) {
 232       java_lang_Throwable::fill_in_stack_trace(exception, method());
 233     }
 234     // Increment counter for hs_err file reporting
 235     Atomic::inc(&Exceptions::_stack_overflow_errors);
 236   } else {
 237     // if prior exception, throw that one instead
 238     exception = Handle(THREAD, THREAD->pending_exception());
 239   }
 240   _throw(THREAD, file, line, exception);
 241 }
 242 
 243 void Exceptions::fthrow(Thread* thread, const char* file, int line, Symbol* h_name, const char* format, ...) {
 244   const int max_msg_size = 1024;
 245   va_list ap;
 246   va_start(ap, format);
 247   char msg[max_msg_size];
 248   vsnprintf(msg, max_msg_size, format, ap);
 249   msg[max_msg_size-1] = '\0';
 250   va_end(ap);


< prev index next >