Clean up creating handles from `this`.
Make these member functions static and take an additional
parameter `Handle<.> h_this`. Callers mostly already have
a Handle<> to pass, so we avoid an extra StackHandleScope.
This pattern was already used for some functions.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --interpreter
Change-Id: I4f4478b0526bcb2f3c23305d3b3cc4a65fff9ff5
diff --git a/runtime/native/java_lang_reflect_Method.cc b/runtime/native/java_lang_reflect_Method.cc
index 4525157..0d9a257 100644
--- a/runtime/native/java_lang_reflect_Method.cc
+++ b/runtime/native/java_lang_reflect_Method.cc
@@ -59,9 +59,11 @@
++i;
}
CHECK_NE(throws_index, -1);
- ObjPtr<mirror::ObjectArray<mirror::Class>> declared_exceptions =
- klass->GetProxyThrows()->Get(throws_index);
- return soa.AddLocalReference<jobjectArray>(declared_exceptions->Clone(soa.Self()));
+ StackHandleScope<1u> hs(soa.Self());
+ Handle<mirror::ObjectArray<mirror::Class>> declared_exceptions =
+ hs.NewHandle(klass->GetProxyThrows()->Get(throws_index));
+ return soa.AddLocalReference<jobjectArray>(
+ mirror::ObjectArray<mirror::Class>::Clone(declared_exceptions, soa.Self()));
} else {
ObjPtr<mirror::ObjectArray<mirror::Class>> result_array =
annotations::GetExceptionTypesForMethod(method);