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/openjdkjvmti/ti_class.cc b/openjdkjvmti/ti_class.cc
index 7537f28..988274b 100644
--- a/openjdkjvmti/ti_class.cc
+++ b/openjdkjvmti/ti_class.cc
@@ -213,7 +213,8 @@
art::StackHandleScope<2> hs(self);
// Save the results of all the non-retransformable agents.
// First allocate the ClassExt
- art::Handle<art::mirror::ClassExt> ext(hs.NewHandle(klass->EnsureExtDataPresent(self)));
+ art::Handle<art::mirror::ClassExt> ext =
+ hs.NewHandle(art::mirror::Class::EnsureExtDataPresent(klass, self));
// Make sure we have a ClassExt. This is fine even though we are a temporary since it will
// get copied.
if (ext.IsNull()) {
diff --git a/openjdkjvmti/ti_redefine.cc b/openjdkjvmti/ti_redefine.cc
index 2474b02..e720317 100644
--- a/openjdkjvmti/ti_redefine.cc
+++ b/openjdkjvmti/ti_redefine.cc
@@ -1603,7 +1603,8 @@
return false;
}
// Allocate the classExt
- art::Handle<art::mirror::ClassExt> ext(hs.NewHandle(klass->EnsureExtDataPresent(driver_->self_)));
+ art::Handle<art::mirror::ClassExt> ext =
+ hs.NewHandle(art::mirror::Class::EnsureExtDataPresent(klass, driver_->self_));
if (ext == nullptr) {
// No memory. Clear exception (it's not useful) and return error.
driver_->self_->AssertPendingOOMException();
@@ -1618,8 +1619,8 @@
// however, since that can happen at any time.
cur_data->SetOldObsoleteMethods(ext->GetObsoleteMethods());
cur_data->SetOldDexCaches(ext->GetObsoleteDexCaches());
- if (!ext->ExtendObsoleteArrays(
- driver_->self_, klass->GetDeclaredMethodsSlice(art::kRuntimePointerSize).size())) {
+ if (!art::mirror::ClassExt::ExtendObsoleteArrays(
+ ext, driver_->self_, klass->GetDeclaredMethodsSlice(art::kRuntimePointerSize).size())) {
// OOM. Clear exception and return error.
driver_->self_->AssertPendingOOMException();
driver_->self_->ClearException();