159 // vm log |
159 // vm log |
160 Events::log("throw_exception " INTPTR_FORMAT, (address)h_exception()); |
160 Events::log("throw_exception " INTPTR_FORMAT, (address)h_exception()); |
161 } |
161 } |
162 |
162 |
163 |
163 |
164 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, symbolHandle h_name, const char* message, Handle h_loader, Handle h_protection_domain) { |
164 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, Symbol* h_name, const char* message, Handle h_loader, Handle h_protection_domain) { |
165 // Check for special boot-strapping/vm-thread handling |
165 // Check for special boot-strapping/vm-thread handling |
166 if (special_exception(thread, file, line, h_name, message)) return; |
166 if (special_exception(thread, file, line, h_name, message)) return; |
167 // Create and throw exception |
167 // Create and throw exception |
168 Handle h_cause(thread, NULL); |
168 Handle h_cause(thread, NULL); |
169 Handle h_exception = new_exception(thread, h_name, message, h_cause, h_loader, h_protection_domain); |
169 Handle h_exception = new_exception(thread, h_name, message, h_cause, h_loader, h_protection_domain); |
170 _throw(thread, file, line, h_exception, message); |
170 _throw(thread, file, line, h_exception, message); |
171 } |
171 } |
172 |
172 |
173 // Throw an exception with a message and a cause |
173 // Throw an exception with a message and a cause |
174 void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, symbolHandle h_name, const char* message, Handle h_cause, Handle h_loader, Handle h_protection_domain) { |
174 void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, Symbol* h_name, const char* message, Handle h_cause, Handle h_loader, Handle h_protection_domain) { |
175 // Check for special boot-strapping/vm-thread handling |
175 // Check for special boot-strapping/vm-thread handling |
176 if (special_exception(thread, file, line, h_name, message)) return; |
176 if (special_exception(thread, file, line, h_name, message)) return; |
177 // Create and throw exception and init cause |
177 // Create and throw exception and init cause |
178 Handle h_exception = new_exception(thread, h_name, message, h_cause, h_loader, h_protection_domain); |
178 Handle h_exception = new_exception(thread, h_name, message, h_cause, h_loader, h_protection_domain); |
179 _throw(thread, file, line, h_exception, message); |
179 _throw(thread, file, line, h_exception, message); |
180 } |
180 } |
181 |
181 |
182 // This version creates handles and calls the other version |
|
183 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, |
|
184 symbolOop name, const char* message) { |
|
185 symbolHandle h_name(thread, name); |
|
186 Handle h_loader(thread, NULL); |
|
187 Handle h_protection_domain(thread, NULL); |
|
188 Exceptions::_throw_msg(thread, file, line, h_name, message, h_loader, h_protection_domain); |
|
189 } |
|
190 |
|
191 // This version already has a handle for name |
182 // This version already has a handle for name |
192 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, |
183 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, |
193 symbolHandle name, const char* message) { |
184 Symbol* name, const char* message) { |
194 Handle h_loader(thread, NULL); |
185 Handle h_loader(thread, NULL); |
195 Handle h_protection_domain(thread, NULL); |
186 Handle h_protection_domain(thread, NULL); |
196 Exceptions::_throw_msg(thread, file, line, name, message, h_loader, h_protection_domain); |
187 Exceptions::_throw_msg(thread, file, line, name, message, h_loader, h_protection_domain); |
197 } |
188 } |
198 |
189 |
199 // This version already has a handle for name |
190 // This version already has a handle for name |
200 void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, |
191 void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, |
201 symbolHandle name, const char* message, Handle cause) { |
192 Symbol* name, const char* message, Handle cause) { |
202 Handle h_loader(thread, NULL); |
193 Handle h_loader(thread, NULL); |
203 Handle h_protection_domain(thread, NULL); |
194 Handle h_protection_domain(thread, NULL); |
204 Exceptions::_throw_msg_cause(thread, file, line, name, message, cause, h_loader, h_protection_domain); |
195 Exceptions::_throw_msg_cause(thread, file, line, name, message, cause, h_loader, h_protection_domain); |
205 } |
196 } |
206 |
197 |
207 void Exceptions::_throw_args(Thread* thread, const char* file, int line, symbolHandle h_name, symbolHandle h_signature, JavaCallArguments *args) { |
198 void Exceptions::_throw_args(Thread* thread, const char* file, int line, Symbol* h_name, Symbol* h_signature, JavaCallArguments *args) { |
208 // Check for special boot-strapping/vm-thread handling |
199 // Check for special boot-strapping/vm-thread handling |
209 if (special_exception(thread, file, line, h_name, NULL)) return; |
200 if (special_exception(thread, file, line, h_name, NULL)) return; |
210 // Create and throw exception |
201 // Create and throw exception |
211 Handle h_loader(thread, NULL); |
202 Handle h_loader(thread, NULL); |
212 Handle h_prot(thread, NULL); |
203 Handle h_prot(thread, NULL); |
307 return h_exception; |
298 return h_exception; |
308 } |
299 } |
309 |
300 |
310 // Convenience method. Calls either the <init>() or <init>(String) method when |
301 // Convenience method. Calls either the <init>() or <init>(String) method when |
311 // creating a new exception |
302 // creating a new exception |
312 Handle Exceptions::new_exception(Thread* thread, symbolHandle h_name, |
303 Handle Exceptions::new_exception(Thread* thread, Symbol* h_name, |
313 const char* message, Handle h_cause, |
304 const char* message, Handle h_cause, |
314 Handle h_loader, |
305 Handle h_loader, |
315 Handle h_protection_domain, |
306 Handle h_protection_domain, |
316 ExceptionMsgToUtf8Mode to_utf8_safe) { |
307 ExceptionMsgToUtf8Mode to_utf8_safe) { |
317 JavaCallArguments args; |
308 JavaCallArguments args; |
318 symbolHandle signature; |
309 Symbol* signature = NULL; |
319 if (message == NULL) { |
310 if (message == NULL) { |
320 signature = vmSymbolHandles::void_method_signature(); |
311 signature = vmSymbols::void_method_signature(); |
321 } else { |
312 } else { |
322 // We want to allocate storage, but we can't do that if there's |
313 // We want to allocate storage, but we can't do that if there's |
323 // a pending exception, so we preserve any pending exception |
314 // a pending exception, so we preserve any pending exception |
324 // around the allocation. |
315 // around the allocation. |
325 // If we get an exception from the allocation, prefer that to |
316 // If we get an exception from the allocation, prefer that to |
360 // convert it directly to a java UTF8 string. Otherwise, we need to take the |
351 // convert it directly to a java UTF8 string. Otherwise, we need to take the |
361 // encoding scheme of the string into account. One thing we should do at some |
352 // encoding scheme of the string into account. One thing we should do at some |
362 // point is to push this flag down to class java_lang_String since other |
353 // point is to push this flag down to class java_lang_String since other |
363 // classes may need similar functionalities. |
354 // classes may need similar functionalities. |
364 Handle Exceptions::new_exception(Thread* thread, |
355 Handle Exceptions::new_exception(Thread* thread, |
365 symbolOop name, |
356 Symbol* name, |
366 const char* message, |
357 const char* message, |
367 ExceptionMsgToUtf8Mode to_utf8_safe) { |
358 ExceptionMsgToUtf8Mode to_utf8_safe) { |
368 |
359 |
369 symbolHandle h_name(thread, name); |
|
370 Handle h_loader(thread, NULL); |
360 Handle h_loader(thread, NULL); |
371 Handle h_prot(thread, NULL); |
361 Handle h_prot(thread, NULL); |
372 Handle h_cause(thread, NULL); |
362 Handle h_cause(thread, NULL); |
373 return Exceptions::new_exception(thread, h_name, message, h_cause, h_loader, |
363 return Exceptions::new_exception(thread, name, message, h_cause, h_loader, |
374 h_prot, to_utf8_safe); |
364 h_prot, to_utf8_safe); |
375 } |
365 } |
376 |
366 |
377 // Implementation of ExceptionMark |
367 // Implementation of ExceptionMark |
378 |
368 |