ART: Fix typo in ArtMethod::FindCatchBlock
The thrown exception is always resolved, as we have an instance of
it. What is potentially not resolved is the catch handler's exception
type.
The resolution failure will trigger a NoClassDefFoundError, which
should replace the original exception. For this, the API has to be
changed a little bit to tell callers that there was this change.
Change-Id: Id51d54a15c732ed175eb617b3b0331b89cbb2051
diff --git a/runtime/catch_block_stack_visitor.cc b/runtime/catch_block_stack_visitor.cc
index b820276..55b330a 100644
--- a/runtime/catch_block_stack_visitor.cc
+++ b/runtime/catch_block_stack_visitor.cc
@@ -50,9 +50,17 @@
}
if (dex_pc != DexFile::kDexNoIndex) {
bool clear_exception = false;
+ bool exc_changed = false;
StackHandleScope<1> hs(Thread::Current());
Handle<mirror::Class> to_find(hs.NewHandle((*exception_)->GetClass()));
- uint32_t found_dex_pc = method->FindCatchBlock(to_find, dex_pc, &clear_exception);
+ uint32_t found_dex_pc = method->FindCatchBlock(to_find, dex_pc, &clear_exception,
+ &exc_changed);
+ if (UNLIKELY(exc_changed)) {
+ DCHECK_EQ(DexFile::kDexNoIndex, found_dex_pc);
+ exception_->Assign(self_->GetException(nullptr)); // TODO: Throw location?
+ // There is a new context installed, delete it.
+ delete self_->GetLongJumpContext();
+ }
exception_handler_->SetClearException(clear_exception);
if (found_dex_pc != DexFile::kDexNoIndex) {
exception_handler_->SetHandlerDexPc(found_dex_pc);