108 109 if (thread->is_VM_thread() 110 || thread->is_Compiler_thread() ) { 111 // We do not care what kind of exception we get for the vm-thread or a thread which 112 // is compiling. We just install a dummy exception object 113 thread->set_pending_exception(Universe::vm_exception(), file, line); 114 return true; 115 } 116 return false; 117 } 118 119 // This method should only be called from generated code, 120 // therefore the exception oop should be in the oopmap. 121 void Exceptions::_throw_oop(Thread* thread, const char* file, int line, oop exception) { 122 assert(exception != NULL, "exception should not be NULL"); 123 Handle h_exception = Handle(thread, exception); 124 _throw(thread, file, line, h_exception); 125 } 126 127 void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception, const char* message) { 128 assert(h_exception() != NULL, "exception should not be NULL"); 129 130 // tracing (do this up front - so it works during boot strapping) 131 if (TraceExceptions) { 132 ttyLocker ttyl; 133 ResourceMark rm; 134 tty->print_cr("Exception <%s>%s%s (" INTPTR_FORMAT " ) \n" 135 "thrown [%s, line %d]\nfor thread " INTPTR_FORMAT, 136 h_exception->print_value_string(), 137 message ? ": " : "", message ? message : "", 138 (address)h_exception(), file, line, thread); 139 } 140 // for AbortVMOnException flag 141 NOT_PRODUCT(Exceptions::debug_check_abort(h_exception, message)); 142 143 // Check for special boot-strapping/vm-thread handling 144 if (special_exception(thread, file, line, h_exception)) return; 145 146 assert(h_exception->is_a(SystemDictionary::Throwable_klass()), "exception is not a subclass of java/lang/Throwable"); 147 148 // set the pending exception 149 thread->set_pending_exception(h_exception(), file, line); 150 151 // vm log 152 Events::log_exception(thread, "Threw " INTPTR_FORMAT " at %s:%d", (address)h_exception(), file, line); 153 } 154 155 156 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, Symbol* name, const char* message, 157 Handle h_loader, Handle h_protection_domain) { 158 // Check for special boot-strapping/vm-thread handling 159 if (special_exception(thread, file, line, name, message)) return; 160 // Create and throw exception 161 Handle h_cause(thread, NULL); 162 Handle h_exception = new_exception(thread, name, message, h_cause, h_loader, h_protection_domain); 163 _throw(thread, file, line, h_exception, message); 164 } 165 166 void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, Symbol* name, const char* message, Handle h_cause, 167 Handle h_loader, Handle h_protection_domain) { 168 // Check for special boot-strapping/vm-thread handling 169 if (special_exception(thread, file, line, name, message)) return; 170 // Create and throw exception and init cause 171 Handle h_exception = new_exception(thread, name, message, h_cause, h_loader, h_protection_domain); 172 _throw(thread, file, line, h_exception, message); | 108 109 if (thread->is_VM_thread() 110 || thread->is_Compiler_thread() ) { 111 // We do not care what kind of exception we get for the vm-thread or a thread which 112 // is compiling. We just install a dummy exception object 113 thread->set_pending_exception(Universe::vm_exception(), file, line); 114 return true; 115 } 116 return false; 117 } 118 119 // This method should only be called from generated code, 120 // therefore the exception oop should be in the oopmap. 121 void Exceptions::_throw_oop(Thread* thread, const char* file, int line, oop exception) { 122 assert(exception != NULL, "exception should not be NULL"); 123 Handle h_exception = Handle(thread, exception); 124 _throw(thread, file, line, h_exception); 125 } 126 127 void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception, const char* message) { 128 ResourceMark rm; 129 assert(h_exception() != NULL, "exception should not be NULL"); 130 131 // tracing (do this up front - so it works during boot strapping) 132 if (TraceExceptions) { 133 ttyLocker ttyl; 134 tty->print_cr("Exception <%s>%s%s (" INTPTR_FORMAT " ) \n" 135 "thrown [%s, line %d]\nfor thread " INTPTR_FORMAT, 136 h_exception->print_value_string(), 137 message ? ": " : "", message ? message : "", 138 (address)h_exception(), file, line, thread); 139 } 140 // for AbortVMOnException flag 141 NOT_PRODUCT(Exceptions::debug_check_abort(h_exception, message)); 142 143 // Check for special boot-strapping/vm-thread handling 144 if (special_exception(thread, file, line, h_exception)) { 145 return; 146 } 147 148 assert(h_exception->is_a(SystemDictionary::Throwable_klass()), "exception is not a subclass of java/lang/Throwable"); 149 150 // set the pending exception 151 thread->set_pending_exception(h_exception(), file, line); 152 153 // vm log 154 Events::log_exception(thread, "threw %s%s%s at %s:%d", h_exception->print_value_string(), message ? ": " : "", message ? message : "", file, line); 155 } 156 157 158 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, Symbol* name, const char* message, 159 Handle h_loader, Handle h_protection_domain) { 160 // Check for special boot-strapping/vm-thread handling 161 if (special_exception(thread, file, line, name, message)) return; 162 // Create and throw exception 163 Handle h_cause(thread, NULL); 164 Handle h_exception = new_exception(thread, name, message, h_cause, h_loader, h_protection_domain); 165 _throw(thread, file, line, h_exception, message); 166 } 167 168 void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, Symbol* name, const char* message, Handle h_cause, 169 Handle h_loader, Handle h_protection_domain) { 170 // Check for special boot-strapping/vm-thread handling 171 if (special_exception(thread, file, line, name, message)) return; 172 // Create and throw exception and init cause 173 Handle h_exception = new_exception(thread, name, message, h_cause, h_loader, h_protection_domain); 174 _throw(thread, file, line, h_exception, message); |