summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/thread.cc12
-rw-r--r--runtime/thread.h1
2 files changed, 12 insertions, 1 deletions
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 8b93b915f0..4fe9169f9b 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -1005,6 +1005,15 @@ void Thread::AssertNoPendingException() const {
}
}
+void Thread::AssertNoPendingExceptionForNewException(const char* msg) const {
+ if (UNLIKELY(IsExceptionPending())) {
+ ScopedObjectAccess soa(Thread::Current());
+ mirror::Throwable* exception = GetException(nullptr);
+ LOG(FATAL) << "Throwing new exception " << msg << " with unexpected pending exception: "
+ << exception->Dump();
+ }
+}
+
static void MonitorExitVisitor(mirror::Object** object, void* arg, uint32_t /*thread_id*/,
RootType /*root_type*/)
NO_THREAD_SAFETY_ANALYSIS {
@@ -1507,7 +1516,8 @@ void Thread::ThrowNewExceptionV(const ThrowLocation& throw_location,
void Thread::ThrowNewException(const ThrowLocation& throw_location, const char* exception_class_descriptor,
const char* msg) {
- AssertNoPendingException(); // Callers should either clear or call ThrowNewWrappedException.
+ // Callers should either clear or call ThrowNewWrappedException.
+ AssertNoPendingExceptionForNewException(msg);
ThrowNewWrappedException(throw_location, exception_class_descriptor, msg);
}
diff --git a/runtime/thread.h b/runtime/thread.h
index 9813130638..f9d31af25d 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -285,6 +285,7 @@ class PACKED(4) Thread {
}
void AssertNoPendingException() const;
+ void AssertNoPendingExceptionForNewException(const char* msg) const;
void SetException(const ThrowLocation& throw_location, mirror::Throwable* new_exception)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {