Refactor java.lang.reflect implementation
Cherry-picked from commit ed41d5c44299ec5d44b8514f6e17f802f48094d1.
Move to ArtMethod/Field instead of AbstractMethod/Field and have
java.lang.reflect APIs delegate to ArtMethod/ArtField.
Bug: 10014286.
Change-Id: Iafc1d8c5b62562c9af8fb9fd8c5e1d61270536e7
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 70d8816..7b12870 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -42,12 +42,11 @@
#include "intern_table.h"
#include "invoke_arg_array_builder.h"
#include "jni_internal.h"
-#include "mirror/abstract_method-inl.h"
+#include "mirror/art_field-inl.h"
+#include "mirror/art_method-inl.h"
#include "mirror/array.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
-#include "mirror/field.h"
-#include "mirror/field-inl.h"
#include "mirror/throwable.h"
#include "monitor.h"
#include "oat_file.h"
@@ -654,7 +653,7 @@
soa.Decode<mirror::Class*>(WellKnownClasses::java_lang_ClassLoader);
CHECK(Runtime::Current()->GetClassLinker()->EnsureInitialized(class_loader_class, true, true));
- mirror::AbstractMethod* getSystemClassLoader =
+ mirror::ArtMethod* getSystemClassLoader =
class_loader_class->FindDirectMethod("getSystemClassLoader", "()Ljava/lang/ClassLoader;");
CHECK(getSystemClassLoader != NULL);
@@ -669,8 +668,8 @@
mirror::Class* thread_class = soa.Decode<mirror::Class*>(WellKnownClasses::java_lang_Thread);
CHECK(Runtime::Current()->GetClassLinker()->EnsureInitialized(thread_class, true, true));
- mirror::Field* contextClassLoader = thread_class->FindDeclaredInstanceField("contextClassLoader",
- "Ljava/lang/ClassLoader;");
+ mirror::ArtField* contextClassLoader = thread_class->FindDeclaredInstanceField("contextClassLoader",
+ "Ljava/lang/ClassLoader;");
CHECK(contextClassLoader != NULL);
contextClassLoader->SetObject(soa.Self()->GetPeer(), class_loader);
@@ -1125,11 +1124,11 @@
VisitNonConcurrentRoots(visitor, arg);
}
-mirror::AbstractMethod* Runtime::CreateResolutionMethod() {
- mirror::Class* method_class = mirror::AbstractMethod::GetMethodClass();
+mirror::ArtMethod* Runtime::CreateResolutionMethod() {
+ mirror::Class* method_class = mirror::ArtMethod::GetJavaLangReflectArtMethod();
Thread* self = Thread::Current();
- SirtRef<mirror::AbstractMethod>
- method(self, down_cast<mirror::AbstractMethod*>(method_class->AllocObject(self)));
+ SirtRef<mirror::ArtMethod>
+ method(self, down_cast<mirror::ArtMethod*>(method_class->AllocObject(self)));
method->SetDeclaringClass(method_class);
// TODO: use a special method for resolution method saves
method->SetDexMethodIndex(DexFile::kDexNoIndex16);
@@ -1140,12 +1139,12 @@
return method.get();
}
-mirror::AbstractMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_set,
+mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_set,
CalleeSaveType type) {
- mirror::Class* method_class = mirror::AbstractMethod::GetMethodClass();
+ mirror::Class* method_class = mirror::ArtMethod::GetJavaLangReflectArtMethod();
Thread* self = Thread::Current();
- SirtRef<mirror::AbstractMethod>
- method(self, down_cast<mirror::AbstractMethod*>(method_class->AllocObject(self)));
+ SirtRef<mirror::ArtMethod>
+ method(self, down_cast<mirror::ArtMethod*>(method_class->AllocObject(self)));
method->SetDeclaringClass(method_class);
// TODO: use a special method for callee saves
method->SetDexMethodIndex(DexFile::kDexNoIndex16);
@@ -1205,7 +1204,7 @@
return method.get();
}
-void Runtime::SetCalleeSaveMethod(mirror::AbstractMethod* method, CalleeSaveType type) {
+void Runtime::SetCalleeSaveMethod(mirror::ArtMethod* method, CalleeSaveType type) {
DCHECK_LT(static_cast<int>(type), static_cast<int>(kLastCalleeSaveType));
callee_save_methods_[type] = method;
}