216 |
216 |
217 |
217 |
218 void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file, int line, const methodHandle& method) { |
218 void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file, int line, const methodHandle& method) { |
219 Handle exception; |
219 Handle exception; |
220 if (!THREAD->has_pending_exception()) { |
220 if (!THREAD->has_pending_exception()) { |
221 Klass* k = SystemDictionary::StackOverflowError_klass(); |
221 InstanceKlass* k = SystemDictionary::StackOverflowError_klass(); |
222 oop e = InstanceKlass::cast(k)->allocate_instance(CHECK); |
222 oop e = k->allocate_instance(CHECK); |
223 exception = Handle(THREAD, e); // fill_in_stack trace does gc |
223 exception = Handle(THREAD, e); // fill_in_stack trace does gc |
224 assert(InstanceKlass::cast(k)->is_initialized(), "need to increase java_thread_min_stack_allowed calculation"); |
224 assert(k->is_initialized(), "need to increase java_thread_min_stack_allowed calculation"); |
225 if (StackTraceInThrowable) { |
225 if (StackTraceInThrowable) { |
226 java_lang_Throwable::fill_in_stack_trace(exception, method()); |
226 java_lang_Throwable::fill_in_stack_trace(exception, method()); |
227 } |
227 } |
228 // Increment counter for hs_err file reporting |
228 // Increment counter for hs_err file reporting |
229 Atomic::inc(&Exceptions::_stack_overflow_errors); |
229 Atomic::inc(&Exceptions::_stack_overflow_errors); |
256 assert(thread->is_Java_thread(), "can only be called by a Java thread"); |
256 assert(thread->is_Java_thread(), "can only be called by a Java thread"); |
257 assert(!thread->has_pending_exception(), "already has exception"); |
257 assert(!thread->has_pending_exception(), "already has exception"); |
258 |
258 |
259 Handle h_exception; |
259 Handle h_exception; |
260 |
260 |
261 // Resolve exception klass |
261 // Resolve exception klass, and check for pending exception below. |
262 InstanceKlass* klass = InstanceKlass::cast(SystemDictionary::resolve_or_fail(name, h_loader, h_protection_domain, true, thread)); |
262 Klass* klass = SystemDictionary::resolve_or_fail(name, h_loader, h_protection_domain, true, thread); |
263 |
263 |
264 if (!thread->has_pending_exception()) { |
264 if (!thread->has_pending_exception()) { |
265 assert(klass != NULL, "klass must exist"); |
265 assert(klass != NULL, "klass must exist"); |
266 // We are about to create an instance - so make sure that klass is initialized |
266 // We are about to create an instance - so make sure that klass is initialized |
267 klass->initialize(thread); |
267 InstanceKlass* ik = InstanceKlass::cast(klass); |
|
268 ik->initialize(thread); |
268 if (!thread->has_pending_exception()) { |
269 if (!thread->has_pending_exception()) { |
269 // Allocate new exception |
270 // Allocate new exception |
270 h_exception = klass->allocate_instance_handle(thread); |
271 h_exception = ik->allocate_instance_handle(thread); |
271 if (!thread->has_pending_exception()) { |
272 if (!thread->has_pending_exception()) { |
272 JavaValue result(T_VOID); |
273 JavaValue result(T_VOID); |
273 args->set_receiver(h_exception); |
274 args->set_receiver(h_exception); |
274 // Call constructor |
275 // Call constructor |
275 JavaCalls::call_special(&result, klass, |
276 JavaCalls::call_special(&result, ik, |
276 vmSymbols::object_initializer_name(), |
277 vmSymbols::object_initializer_name(), |
277 signature, |
278 signature, |
278 args, |
279 args, |
279 thread); |
280 thread); |
280 } |
281 } |
281 } |
282 } |
282 } |
283 } |
283 |
284 |
284 // Check if another exception was thrown in the process, if so rethrow that one |
285 // Check if another exception was thrown in the process, if so rethrow that one |