86 // Check for trying to throw stack overflow before initialization is complete |
86 // Check for trying to throw stack overflow before initialization is complete |
87 // to prevent infinite recursion trying to initialize stack overflow without |
87 // to prevent infinite recursion trying to initialize stack overflow without |
88 // adequate stack space. |
88 // adequate stack space. |
89 // This can happen with stress testing a large value of StackShadowPages |
89 // This can happen with stress testing a large value of StackShadowPages |
90 if (h_exception()->klass() == SystemDictionary::StackOverflowError_klass()) { |
90 if (h_exception()->klass() == SystemDictionary::StackOverflowError_klass()) { |
91 instanceKlass* ik = instanceKlass::cast(h_exception->klass()); |
91 InstanceKlass* ik = InstanceKlass::cast(h_exception->klass()); |
92 assert(ik->is_initialized(), |
92 assert(ik->is_initialized(), |
93 "need to increase min_stack_allowed calculation"); |
93 "need to increase min_stack_allowed calculation"); |
94 } |
94 } |
95 #endif // ASSERT |
95 #endif // ASSERT |
96 |
96 |
217 |
217 |
218 |
218 |
219 void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file, int line, methodHandle method) { |
219 void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file, int line, methodHandle method) { |
220 Handle exception; |
220 Handle exception; |
221 if (!THREAD->has_pending_exception()) { |
221 if (!THREAD->has_pending_exception()) { |
222 klassOop k = SystemDictionary::StackOverflowError_klass(); |
222 Klass* k = SystemDictionary::StackOverflowError_klass(); |
223 oop e = instanceKlass::cast(k)->allocate_instance(CHECK); |
223 oop e = InstanceKlass::cast(k)->allocate_instance(CHECK); |
224 exception = Handle(THREAD, e); // fill_in_stack trace does gc |
224 exception = Handle(THREAD, e); // fill_in_stack trace does gc |
225 assert(instanceKlass::cast(k)->is_initialized(), "need to increase min_stack_allowed calculation"); |
225 assert(InstanceKlass::cast(k)->is_initialized(), "need to increase min_stack_allowed calculation"); |
226 if (StackTraceInThrowable) { |
226 if (StackTraceInThrowable) { |
227 java_lang_Throwable::fill_in_stack_trace(exception, method()); |
227 java_lang_Throwable::fill_in_stack_trace(exception, method()); |
228 } |
228 } |
229 } else { |
229 } else { |
230 // if prior exception, throw that one instead |
230 // if prior exception, throw that one instead |
255 assert(!thread->has_pending_exception(), "already has exception"); |
255 assert(!thread->has_pending_exception(), "already has exception"); |
256 |
256 |
257 Handle h_exception; |
257 Handle h_exception; |
258 |
258 |
259 // Resolve exception klass |
259 // Resolve exception klass |
260 klassOop ik = SystemDictionary::resolve_or_fail(name, h_loader, h_protection_domain, true, thread); |
260 Klass* ik = SystemDictionary::resolve_or_fail(name, h_loader, h_protection_domain, true, thread); |
261 instanceKlassHandle klass(thread, ik); |
261 instanceKlassHandle klass(thread, ik); |
262 |
262 |
263 if (!thread->has_pending_exception()) { |
263 if (!thread->has_pending_exception()) { |
264 assert(klass.not_null(), "klass must exist"); |
264 assert(klass.not_null(), "klass must exist"); |
265 // We are about to create an instance - so make sure that klass is initialized |
265 // We are about to create an instance - so make sure that klass is initialized |