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_Object.cc b/runtime/native/java_lang_Object.cc
index 48540f8..8fc10d1 100644
--- a/runtime/native/java_lang_Object.cc
+++ b/runtime/native/java_lang_Object.cc
@@ -18,6 +18,7 @@
#include "nativehelper/jni_macros.h"
+#include "handle_scope-inl.h"
#include "jni/jni_internal.h"
#include "mirror/object-inl.h"
#include "native_util.h"
@@ -27,8 +28,9 @@
static jobject Object_internalClone(JNIEnv* env, jobject java_this) {
ScopedFastNativeObjectAccess soa(env);
- ObjPtr<mirror::Object> o = soa.Decode<mirror::Object>(java_this);
- return soa.AddLocalReference<jobject>(o->Clone(soa.Self()));
+ StackHandleScope<1u> hs(soa.Self());
+ Handle<mirror::Object> o = hs.NewHandle(soa.Decode<mirror::Object>(java_this));
+ return soa.AddLocalReference<jobject>(mirror::Class::Clone(o, soa.Self()));
}
static void Object_notify(JNIEnv* env, jobject java_this) {