Fix HasSameSignatureWithDifferentClassLoaders().
Add a missing handle and make sure that the handle's
Get() is sequenced after the call that can cause GC.
Change-Id: I3c0479650c40ceb803bfbf658238aeea8e4b0a1a
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index e0df6db..178d6e7 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4297,7 +4297,9 @@
{
StackHandleScope<1> hs(self);
Handle<mirror::Class> return_type(hs.NewHandle(method1->GetReturnType()));
- if (UNLIKELY(method2->GetReturnType() != return_type.Get())) {
+ mirror::Class* other_return_type = method2->GetReturnType();
+ // NOTE: return_type.Get() must be sequenced after method2->GetReturnType().
+ if (UNLIKELY(other_return_type != return_type.Get())) {
return false;
}
}
@@ -4313,11 +4315,13 @@
return false;
}
for (uint32_t i = 0; i < num_types; ++i) {
- mirror::Class* param_type =
- method1->GetClassFromTypeIndex(types1->GetTypeItem(i).type_idx_, true);
+ StackHandleScope<1> hs(self);
+ Handle<mirror::Class> param_type(hs.NewHandle(
+ method1->GetClassFromTypeIndex(types1->GetTypeItem(i).type_idx_, true)));
mirror::Class* other_param_type =
method2->GetClassFromTypeIndex(types2->GetTypeItem(i).type_idx_, true);
- if (UNLIKELY(param_type != other_param_type)) {
+ // NOTE: param_type.Get() must be sequenced after method2->GetClassFromTypeIndex(...).
+ if (UNLIKELY(param_type.Get() != other_param_type)) {
return false;
}
}