66 LogTarget(Debug, exceptions) lt;
67 if (_pending_exception != nullptr && lt.is_enabled()) {
68 ResourceMark rm;
69 LogStream ls(lt);
70 ls.print("Thread::clear_pending_exception: cleared exception:");
71 _pending_exception->print_on(&ls);
72 }
73 _pending_exception = nullptr;
74 _exception_file = nullptr;
75 _exception_line = 0;
76 }
77
78 void ThreadShadow::clear_pending_nonasync_exception() {
79 // Do not clear probable async exceptions.
80 if ((_pending_exception->klass() != vmClasses::InternalError_klass() ||
81 java_lang_InternalError::during_unsafe_access(_pending_exception) != JNI_TRUE)) {
82 clear_pending_exception();
83 }
84 }
85
86 // Implementation of Exceptions
87
88 bool Exceptions::special_exception(JavaThread* thread, const char* file, int line, Handle h_exception, Symbol* h_name, const char* message) {
89 assert(h_exception.is_null() != (h_name == nullptr), "either exception (" PTR_FORMAT ") or "
90 "symbol (" PTR_FORMAT ") must be non-null but not both", p2i(h_exception()), p2i(h_name));
91
92 // bootstrapping check
93 if (!Universe::is_fully_initialized()) {
94 if (h_exception.not_null()) {
95 vm_exit_during_initialization(h_exception);
96 } else if (h_name == nullptr) {
97 // at least an informative message.
98 vm_exit_during_initialization("Exception", message);
99 } else {
100 vm_exit_during_initialization(h_name, message);
101 }
102 ShouldNotReachHere();
103 }
104
105 #ifdef ASSERT
|
66 LogTarget(Debug, exceptions) lt;
67 if (_pending_exception != nullptr && lt.is_enabled()) {
68 ResourceMark rm;
69 LogStream ls(lt);
70 ls.print("Thread::clear_pending_exception: cleared exception:");
71 _pending_exception->print_on(&ls);
72 }
73 _pending_exception = nullptr;
74 _exception_file = nullptr;
75 _exception_line = 0;
76 }
77
78 void ThreadShadow::clear_pending_nonasync_exception() {
79 // Do not clear probable async exceptions.
80 if ((_pending_exception->klass() != vmClasses::InternalError_klass() ||
81 java_lang_InternalError::during_unsafe_access(_pending_exception) != JNI_TRUE)) {
82 clear_pending_exception();
83 }
84 }
85
86 void ThreadShadow::set_pending_preempted_exception() {
87 assert(!has_pending_exception(), "");
88 // We always install the same dummy exception since we only want
89 // to use the TRAPS mechaninsm to bail out from all methods until
90 // reaching the one using the CHECK_AND_CLEAR_PREEMPTED macro.
91 set_pending_exception(Universe::preempted_exception_instance(), __FILE__, __LINE__);
92 }
93
94 void ThreadShadow::clear_pending_preempted_exception() {
95 if (_pending_exception->klass() == vmClasses::PreemptedException_klass()) {
96 clear_pending_exception();
97 }
98 }
99
100 #ifdef ASSERT
101 void ThreadShadow::check_preempted_exception() {
102 assert(has_pending_exception(), "");
103 assert(pending_exception()->is_a(vmClasses::PreemptedException_klass()), "");
104 }
105 #endif
106
107 // Implementation of Exceptions
108
109 bool Exceptions::special_exception(JavaThread* thread, const char* file, int line, Handle h_exception, Symbol* h_name, const char* message) {
110 assert(h_exception.is_null() != (h_name == nullptr), "either exception (" PTR_FORMAT ") or "
111 "symbol (" PTR_FORMAT ") must be non-null but not both", p2i(h_exception()), p2i(h_name));
112
113 // bootstrapping check
114 if (!Universe::is_fully_initialized()) {
115 if (h_exception.not_null()) {
116 vm_exit_during_initialization(h_exception);
117 } else if (h_name == nullptr) {
118 // at least an informative message.
119 vm_exit_during_initialization("Exception", message);
120 } else {
121 vm_exit_during_initialization(h_name, message);
122 }
123 ShouldNotReachHere();
124 }
125
126 #ifdef ASSERT
|