ObjPtr<>-ify ClassLinker::FindClass(), fix 1 stale reference use.
Thread::CreateAnnotatedStackTrace() was using a stale
reference `aste_array_class`.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 31113334
Change-Id: I191907c0053456bb57de425aa6ccd9668df818a2
diff --git a/runtime/native/java_lang_reflect_Executable.cc b/runtime/native/java_lang_reflect_Executable.cc
index 9a2d302..a40cb9b 100644
--- a/runtime/native/java_lang_reflect_Executable.cc
+++ b/runtime/native/java_lang_reflect_Executable.cc
@@ -20,6 +20,7 @@
#include "nativehelper/jni_macros.h"
#include "art_method-inl.h"
+#include "class_root.h"
#include "dex/dex_file_annotations.h"
#include "handle.h"
#include "jni/jni_internal.h"
@@ -335,15 +336,6 @@
return soa.AddLocalReference<jclass>(return_type);
}
-// TODO: Move this to mirror::Class ? Other mirror types that commonly appear
-// as arrays have a GetArrayClass() method. This is duplicated in
-// java_lang_Class.cc as well.
-static ObjPtr<mirror::Class> GetClassArrayClass(Thread* self)
- REQUIRES_SHARED(Locks::mutator_lock_) {
- ObjPtr<mirror::Class> class_class = mirror::Class::GetJavaLangClass();
- return Runtime::Current()->GetClassLinker()->FindArrayClass(self, &class_class);
-}
-
static jobjectArray Executable_getParameterTypesInternal(JNIEnv* env, jobject javaMethod) {
ScopedFastNativeObjectAccess soa(env);
ArtMethod* method = ArtMethod::FromReflectedMethod(soa, javaMethod);
@@ -356,10 +348,10 @@
const uint32_t num_params = params->Size();
- StackHandleScope<3> hs(soa.Self());
- Handle<mirror::Class> class_array_class = hs.NewHandle(GetClassArrayClass(soa.Self()));
+ StackHandleScope<2> hs(soa.Self());
+ ObjPtr<mirror::Class> class_array_class = GetClassRoot<mirror::ObjectArray<mirror::Class>>();
Handle<mirror::ObjectArray<mirror::Class>> ptypes = hs.NewHandle(
- mirror::ObjectArray<mirror::Class>::Alloc(soa.Self(), class_array_class.Get(), num_params));
+ mirror::ObjectArray<mirror::Class>::Alloc(soa.Self(), class_array_class, num_params));
if (ptypes.IsNull()) {
DCHECK(soa.Self()->IsExceptionPending());
return nullptr;