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/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h
index af8b534..9b03334 100644
--- a/runtime/interpreter/interpreter_common.h
+++ b/runtime/interpreter/interpreter_common.h
@@ -572,10 +572,16 @@
ThrowLocation throw_location;
mirror::Throwable* exception = self->GetException(&throw_location);
bool clear_exception = false;
+ bool new_exception = false;
StackHandleScope<3> hs(self);
Handle<mirror::Class> exception_class(hs.NewHandle(exception->GetClass()));
uint32_t found_dex_pc = shadow_frame.GetMethod()->FindCatchBlock(exception_class, dex_pc,
- &clear_exception);
+ &clear_exception,
+ &new_exception);
+ if (UNLIKELY(new_exception)) {
+ // Update the exception.
+ exception = self->GetException(&throw_location);
+ }
if (found_dex_pc == DexFile::kDexNoIndex) {
instrumentation->MethodUnwindEvent(self, this_object,
shadow_frame.GetMethod(), dex_pc);