Mercurial > hg > graal-jvmci-8
annotate src/share/vm/utilities/exceptions.cpp @ 4978:99d3d8a72252
More ifdef GRAAL usage.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 27 Feb 2012 18:31:27 +0100 |
parents | 33df1aeaebbf |
children | 1b8d02e10ee8 |
rev | line source |
---|---|
0 | 1 /* |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
3960
diff
changeset
|
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/systemDictionary.hpp" | |
27 #include "classfile/vmSymbols.hpp" | |
28 #include "compiler/compileBroker.hpp" | |
29 #include "oops/oop.inline.hpp" | |
30 #include "runtime/init.hpp" | |
31 #include "runtime/java.hpp" | |
32 #include "runtime/javaCalls.hpp" | |
33 #include "runtime/threadCritical.hpp" | |
34 #include "utilities/events.hpp" | |
35 #include "utilities/exceptions.hpp" | |
36 #ifdef TARGET_OS_FAMILY_linux | |
37 # include "thread_linux.inline.hpp" | |
38 #endif | |
39 #ifdef TARGET_OS_FAMILY_solaris | |
40 # include "thread_solaris.inline.hpp" | |
41 #endif | |
42 #ifdef TARGET_OS_FAMILY_windows | |
43 # include "thread_windows.inline.hpp" | |
44 #endif | |
3960 | 45 #ifdef TARGET_OS_FAMILY_bsd |
46 # include "thread_bsd.inline.hpp" | |
47 #endif | |
0 | 48 |
49 | |
50 // Implementation of ThreadShadow | |
51 void check_ThreadShadow() { | |
52 const ByteSize offset1 = byte_offset_of(ThreadShadow, _pending_exception); | |
53 const ByteSize offset2 = Thread::pending_exception_offset(); | |
54 if (offset1 != offset2) fatal("ThreadShadow::_pending_exception is not positioned correctly"); | |
55 } | |
56 | |
57 | |
58 void ThreadShadow::set_pending_exception(oop exception, const char* file, int line) { | |
59 assert(exception != NULL && exception->is_oop(), "invalid exception oop"); | |
60 _pending_exception = exception; | |
61 _exception_file = file; | |
62 _exception_line = line; | |
63 } | |
64 | |
65 void ThreadShadow::clear_pending_exception() { | |
66 if (TraceClearedExceptions) { | |
67 if (_pending_exception != NULL) { | |
68 tty->print_cr("Thread::clear_pending_exception: cleared exception:"); | |
69 _pending_exception->print(); | |
70 } | |
71 } | |
72 _pending_exception = NULL; | |
73 _exception_file = NULL; | |
74 _exception_line = 0; | |
75 } | |
76 // Implementation of Exceptions | |
77 | |
78 bool Exceptions::special_exception(Thread* thread, const char* file, int line, Handle h_exception) { | |
79 // bootstrapping check | |
80 if (!Universe::is_fully_initialized()) { | |
81 vm_exit_during_initialization(h_exception); | |
82 ShouldNotReachHere(); | |
83 } | |
84 | |
1867
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
85 #ifdef ASSERT |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
86 // Check for trying to throw stack overflow before initialization is complete |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
87 // to prevent infinite recursion trying to initialize stack overflow without |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
88 // adequate stack space. |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
89 // This can happen with stress testing a large value of StackShadowPages |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
90 if (h_exception()->klass() == SystemDictionary::StackOverflowError_klass()) { |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
91 instanceKlass* ik = instanceKlass::cast(h_exception->klass()); |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
92 assert(ik->is_initialized(), |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
93 "need to increase min_stack_allowed calculation"); |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
94 } |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
95 #endif // ASSERT |
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
96 |
0 | 97 if (thread->is_VM_thread() |
4978
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
98 #ifndef GRAAL |
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
99 || thread->is_Compiler_thread() |
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
100 #endif |
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
101 ) { |
0 | 102 // We do not care what kind of exception we get for the vm-thread or a thread which |
103 // is compiling. We just install a dummy exception object | |
104 thread->set_pending_exception(Universe::vm_exception(), file, line); | |
105 return true; | |
106 } | |
107 | |
108 return false; | |
109 } | |
110 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
111 bool Exceptions::special_exception(Thread* thread, const char* file, int line, Symbol* h_name, const char* message) { |
0 | 112 // bootstrapping check |
113 if (!Universe::is_fully_initialized()) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
114 if (h_name == NULL) { |
0 | 115 // atleast an informative message. |
116 vm_exit_during_initialization("Exception", message); | |
117 } else { | |
118 vm_exit_during_initialization(h_name, message); | |
119 } | |
120 ShouldNotReachHere(); | |
121 } | |
122 | |
123 if (thread->is_VM_thread() | |
4978
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
124 #ifndef GRAAL |
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
125 || thread->is_Compiler_thread() |
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
126 #endif |
99d3d8a72252
More ifdef GRAAL usage.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4970
diff
changeset
|
127 ) { |
0 | 128 // We do not care what kind of exception we get for the vm-thread or a thread which |
129 // is compiling. We just install a dummy exception object | |
130 thread->set_pending_exception(Universe::vm_exception(), file, line); | |
131 return true; | |
132 } | |
133 return false; | |
134 } | |
135 | |
136 // This method should only be called from generated code, | |
137 // therefore the exception oop should be in the oopmap. | |
138 void Exceptions::_throw_oop(Thread* thread, const char* file, int line, oop exception) { | |
139 assert(exception != NULL, "exception should not be NULL"); | |
140 Handle h_exception = Handle(thread, exception); | |
141 _throw(thread, file, line, h_exception); | |
142 } | |
143 | |
1011
fcb148c6b605
6889302: TraceExceptions output should include detail message
never
parents:
0
diff
changeset
|
144 void Exceptions::_throw(Thread* thread, const char* file, int line, Handle h_exception, const char* message) { |
0 | 145 assert(h_exception() != NULL, "exception should not be NULL"); |
146 | |
147 // tracing (do this up front - so it works during boot strapping) | |
148 if (TraceExceptions) { | |
149 ttyLocker ttyl; | |
150 ResourceMark rm; | |
1011
fcb148c6b605
6889302: TraceExceptions output should include detail message
never
parents:
0
diff
changeset
|
151 tty->print_cr("Exception <%s>%s%s (" INTPTR_FORMAT " ) \n" |
fcb148c6b605
6889302: TraceExceptions output should include detail message
never
parents:
0
diff
changeset
|
152 "thrown [%s, line %d]\nfor thread " INTPTR_FORMAT, |
fcb148c6b605
6889302: TraceExceptions output should include detail message
never
parents:
0
diff
changeset
|
153 h_exception->print_value_string(), |
fcb148c6b605
6889302: TraceExceptions output should include detail message
never
parents:
0
diff
changeset
|
154 message ? ": " : "", message ? message : "", |
fcb148c6b605
6889302: TraceExceptions output should include detail message
never
parents:
0
diff
changeset
|
155 (address)h_exception(), file, line, thread); |
0 | 156 } |
157 // for AbortVMOnException flag | |
1684
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
158 NOT_PRODUCT(Exceptions::debug_check_abort(h_exception, message)); |
0 | 159 |
160 // Check for special boot-strapping/vm-thread handling | |
161 if (special_exception(thread, file, line, h_exception)) return; | |
162 | |
1142 | 163 assert(h_exception->is_a(SystemDictionary::Throwable_klass()), "exception is not a subclass of java/lang/Throwable"); |
0 | 164 |
165 // set the pending exception | |
166 thread->set_pending_exception(h_exception(), file, line); | |
167 | |
168 // vm log | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
3960
diff
changeset
|
169 Events::log_exception(thread, "Threw " INTPTR_FORMAT " at %s:%d", (address)h_exception(), file, line); |
0 | 170 } |
171 | |
172 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
173 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, Symbol* h_name, const char* message, Handle h_loader, Handle h_protection_domain) { |
0 | 174 // Check for special boot-strapping/vm-thread handling |
175 if (special_exception(thread, file, line, h_name, message)) return; | |
176 // Create and throw exception | |
177 Handle h_cause(thread, NULL); | |
178 Handle h_exception = new_exception(thread, h_name, message, h_cause, h_loader, h_protection_domain); | |
1011
fcb148c6b605
6889302: TraceExceptions output should include detail message
never
parents:
0
diff
changeset
|
179 _throw(thread, file, line, h_exception, message); |
0 | 180 } |
181 | |
182 // Throw an exception with a message and a cause | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
183 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) { |
0 | 184 // Check for special boot-strapping/vm-thread handling |
185 if (special_exception(thread, file, line, h_name, message)) return; | |
186 // Create and throw exception and init cause | |
187 Handle h_exception = new_exception(thread, h_name, message, h_cause, h_loader, h_protection_domain); | |
1011
fcb148c6b605
6889302: TraceExceptions output should include detail message
never
parents:
0
diff
changeset
|
188 _throw(thread, file, line, h_exception, message); |
0 | 189 } |
190 | |
191 // This version already has a handle for name | |
192 void Exceptions::_throw_msg(Thread* thread, const char* file, int line, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
193 Symbol* name, const char* message) { |
0 | 194 Handle h_loader(thread, NULL); |
195 Handle h_protection_domain(thread, NULL); | |
196 Exceptions::_throw_msg(thread, file, line, name, message, h_loader, h_protection_domain); | |
197 } | |
198 | |
199 // This version already has a handle for name | |
200 void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
201 Symbol* name, const char* message, Handle cause) { |
0 | 202 Handle h_loader(thread, NULL); |
203 Handle h_protection_domain(thread, NULL); | |
204 Exceptions::_throw_msg_cause(thread, file, line, name, message, cause, h_loader, h_protection_domain); | |
205 } | |
206 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
207 void Exceptions::_throw_args(Thread* thread, const char* file, int line, Symbol* h_name, Symbol* h_signature, JavaCallArguments *args) { |
0 | 208 // Check for special boot-strapping/vm-thread handling |
209 if (special_exception(thread, file, line, h_name, NULL)) return; | |
210 // Create and throw exception | |
211 Handle h_loader(thread, NULL); | |
212 Handle h_prot(thread, NULL); | |
213 Handle h_cause(thread, NULL); | |
214 Handle exception = new_exception(thread, h_name, h_signature, args, h_cause, h_loader, h_prot); | |
215 _throw(thread, file, line, exception); | |
216 } | |
217 | |
218 | |
3272
01147d8aac1d
7009923: JSR 292: VM crash in JavaThread::last_frame
coleenp
parents:
2426
diff
changeset
|
219 void Exceptions::throw_stack_overflow_exception(Thread* THREAD, const char* file, int line, methodHandle method) { |
0 | 220 Handle exception; |
221 if (!THREAD->has_pending_exception()) { | |
222 klassOop k = SystemDictionary::StackOverflowError_klass(); | |
223 oop e = instanceKlass::cast(k)->allocate_instance(CHECK); | |
224 exception = Handle(THREAD, e); // fill_in_stack trace does gc | |
1867
b6aedd1acdc0
6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
coleenp
parents:
1684
diff
changeset
|
225 assert(instanceKlass::cast(k)->is_initialized(), "need to increase min_stack_allowed calculation"); |
0 | 226 if (StackTraceInThrowable) { |
3272
01147d8aac1d
7009923: JSR 292: VM crash in JavaThread::last_frame
coleenp
parents:
2426
diff
changeset
|
227 java_lang_Throwable::fill_in_stack_trace(exception, method()); |
0 | 228 } |
229 } else { | |
230 // if prior exception, throw that one instead | |
231 exception = Handle(THREAD, THREAD->pending_exception()); | |
232 } | |
3272
01147d8aac1d
7009923: JSR 292: VM crash in JavaThread::last_frame
coleenp
parents:
2426
diff
changeset
|
233 _throw(THREAD, file, line, exception); |
0 | 234 } |
235 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
236 void Exceptions::fthrow(Thread* thread, const char* file, int line, Symbol* h_name, const char* format, ...) { |
0 | 237 const int max_msg_size = 1024; |
238 va_list ap; | |
239 va_start(ap, format); | |
240 char msg[max_msg_size]; | |
241 vsnprintf(msg, max_msg_size, format, ap); | |
242 msg[max_msg_size-1] = '\0'; | |
243 va_end(ap); | |
244 _throw_msg(thread, file, line, h_name, msg); | |
245 } | |
246 | |
247 // Creates an exception oop, calls the <init> method with the given signature. | |
248 // and returns a Handle | |
249 // Initializes the cause if cause non-null | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
250 Handle Exceptions::new_exception(Thread *thread, Symbol* h_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
251 Symbol* signature, |
0 | 252 JavaCallArguments *args, |
253 Handle h_cause, Handle h_loader, | |
254 Handle h_protection_domain) { | |
255 assert(Universe::is_fully_initialized(), | |
256 "cannot be called during initialization"); | |
257 assert(thread->is_Java_thread(), "can only be called by a Java thread"); | |
258 assert(!thread->has_pending_exception(), "already has exception"); | |
259 | |
260 Handle h_exception; | |
261 | |
262 // Resolve exception klass | |
263 klassOop ik = SystemDictionary::resolve_or_fail(h_name, h_loader, h_protection_domain, true, thread); | |
264 instanceKlassHandle klass (thread, ik); | |
265 | |
266 if (!thread->has_pending_exception()) { | |
267 assert(klass.not_null(), "klass must exist"); | |
268 // We are about to create an instance - so make sure that klass is initialized | |
269 klass->initialize(thread); | |
270 if (!thread->has_pending_exception()) { | |
271 // Allocate new exception | |
272 h_exception = klass->allocate_instance_handle(thread); | |
273 if (!thread->has_pending_exception()) { | |
274 JavaValue result(T_VOID); | |
275 args->set_receiver(h_exception); | |
276 // Call constructor | |
277 JavaCalls::call_special(&result, klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
278 vmSymbols::object_initializer_name(), |
0 | 279 signature, |
280 args, | |
281 thread); | |
282 | |
283 } | |
284 } | |
285 | |
286 // Future: object initializer should take a cause argument | |
287 if (h_cause() != NULL) { | |
1142 | 288 assert(h_cause->is_a(SystemDictionary::Throwable_klass()), |
0 | 289 "exception cause is not a subclass of java/lang/Throwable"); |
290 JavaValue result1(T_OBJECT); | |
291 JavaCallArguments args1; | |
292 args1.set_receiver(h_exception); | |
293 args1.push_oop(h_cause); | |
294 JavaCalls::call_virtual(&result1, klass, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
295 vmSymbols::initCause_name(), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
296 vmSymbols::throwable_throwable_signature(), |
0 | 297 &args1, |
298 thread); | |
299 } | |
300 } | |
301 | |
302 // Check if another exception was thrown in the process, if so rethrow that one | |
303 if (thread->has_pending_exception()) { | |
304 h_exception = Handle(thread, thread->pending_exception()); | |
305 thread->clear_pending_exception(); | |
306 } | |
307 return h_exception; | |
308 } | |
309 | |
310 // Convenience method. Calls either the <init>() or <init>(String) method when | |
311 // creating a new exception | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
312 Handle Exceptions::new_exception(Thread* thread, Symbol* h_name, |
0 | 313 const char* message, Handle h_cause, |
314 Handle h_loader, | |
315 Handle h_protection_domain, | |
316 ExceptionMsgToUtf8Mode to_utf8_safe) { | |
317 JavaCallArguments args; | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
318 Symbol* signature = NULL; |
0 | 319 if (message == NULL) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
320 signature = vmSymbols::void_method_signature(); |
0 | 321 } else { |
322 // We want to allocate storage, but we can't do that if there's | |
323 // a pending exception, so we preserve any pending exception | |
324 // around the allocation. | |
325 // If we get an exception from the allocation, prefer that to | |
326 // the exception we are trying to build, or the pending exception. | |
327 // This is sort of like what PRESERVE_EXCEPTION_MARK does, except | |
328 // for the preferencing and the early returns. | |
329 Handle incoming_exception (thread, NULL); | |
330 if (thread->has_pending_exception()) { | |
331 incoming_exception = Handle(thread, thread->pending_exception()); | |
332 thread->clear_pending_exception(); | |
333 } | |
334 Handle msg; | |
335 if (to_utf8_safe == safe_to_utf8) { | |
336 // Make a java UTF8 string. | |
337 msg = java_lang_String::create_from_str(message, thread); | |
338 } else { | |
339 // Make a java string keeping the encoding scheme of the original string. | |
340 msg = java_lang_String::create_from_platform_dependent_str(message, thread); | |
341 } | |
342 if (thread->has_pending_exception()) { | |
343 Handle exception(thread, thread->pending_exception()); | |
344 thread->clear_pending_exception(); | |
345 return exception; | |
346 } | |
347 if (incoming_exception.not_null()) { | |
348 return incoming_exception; | |
349 } | |
350 args.push_oop(msg); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
351 signature = vmSymbols::string_void_signature(); |
0 | 352 } |
353 return new_exception(thread, h_name, signature, &args, h_cause, h_loader, h_protection_domain); | |
354 } | |
355 | |
356 // Another convenience method that creates handles for null class loaders and | |
357 // protection domains and null causes. | |
358 // If the last parameter 'to_utf8_mode' is safe_to_utf8, | |
359 // it means we can safely ignore the encoding scheme of the message string and | |
360 // 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 | |
362 // point is to push this flag down to class java_lang_String since other | |
363 // classes may need similar functionalities. | |
364 Handle Exceptions::new_exception(Thread* thread, | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
365 Symbol* name, |
0 | 366 const char* message, |
367 ExceptionMsgToUtf8Mode to_utf8_safe) { | |
368 | |
369 Handle h_loader(thread, NULL); | |
370 Handle h_prot(thread, NULL); | |
371 Handle h_cause(thread, NULL); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
372 return Exceptions::new_exception(thread, name, message, h_cause, h_loader, |
0 | 373 h_prot, to_utf8_safe); |
374 } | |
375 | |
376 // Implementation of ExceptionMark | |
377 | |
378 ExceptionMark::ExceptionMark(Thread*& thread) { | |
379 thread = Thread::current(); | |
380 _thread = thread; | |
381 if (_thread->has_pending_exception()) { | |
382 oop exception = _thread->pending_exception(); | |
383 _thread->clear_pending_exception(); // Needed to avoid infinite recursion | |
384 exception->print(); | |
385 fatal("ExceptionMark constructor expects no pending exceptions"); | |
386 } | |
387 } | |
388 | |
389 | |
390 ExceptionMark::~ExceptionMark() { | |
391 if (_thread->has_pending_exception()) { | |
392 Handle exception(_thread, _thread->pending_exception()); | |
393 _thread->clear_pending_exception(); // Needed to avoid infinite recursion | |
394 if (is_init_completed()) { | |
395 exception->print(); | |
396 fatal("ExceptionMark destructor expects no pending exceptions"); | |
397 } else { | |
398 vm_exit_during_initialization(exception); | |
399 } | |
400 } | |
401 } | |
402 | |
403 // ---------------------------------------------------------------------------------------- | |
404 | |
405 #ifndef PRODUCT | |
406 // caller frees value_string if necessary | |
1684
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
407 void Exceptions::debug_check_abort(const char *value_string, const char* message) { |
0 | 408 if (AbortVMOnException != NULL && value_string != NULL && |
409 strstr(value_string, AbortVMOnException)) { | |
1684
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
410 if (AbortVMOnExceptionMessage == NULL || message == NULL || |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
411 strcmp(message, AbortVMOnExceptionMessage) == 0) { |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
412 fatal(err_msg("Saw %s, aborting", value_string)); |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
413 } |
0 | 414 } |
415 } | |
416 | |
1684
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
417 void Exceptions::debug_check_abort(Handle exception, const char* message) { |
0 | 418 if (AbortVMOnException != NULL) { |
419 ResourceMark rm; | |
1684
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
420 if (message == NULL && exception->is_a(SystemDictionary::Throwable_klass())) { |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
421 oop msg = java_lang_Throwable::message(exception); |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
422 if (msg != NULL) { |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
423 message = java_lang_String::as_utf8_string(msg); |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
424 } |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
425 } |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
426 debug_check_abort(instanceKlass::cast(exception()->klass())->external_name(), message); |
0 | 427 } |
428 } | |
429 #endif |