Remove mirror:: and ArtMethod deps in utils.{h,cc}
The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance. This episode
finds us removing references to ArtMethod/ArtField/mirror.
One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument. I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful. I have tried to remove as many cases
as possible where it was clear p != nullptr.
Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index f2bda05..29dda88 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -235,8 +235,8 @@
void* FindNativeMethod(ArtMethod* m, std::string& detail)
REQUIRES(Locks::jni_libraries_lock_)
REQUIRES_SHARED(Locks::mutator_lock_) {
- std::string jni_short_name(JniShortName(m));
- std::string jni_long_name(JniLongName(m));
+ std::string jni_short_name(m->JniShortName());
+ std::string jni_long_name(m->JniLongName());
mirror::ClassLoader* const declaring_class_loader = m->GetDeclaringClass()->GetClassLoader();
ScopedObjectAccessUnchecked soa(Thread::Current());
void* const declaring_class_loader_allocator =
@@ -258,13 +258,13 @@
fn = library->FindSymbol(jni_long_name, shorty);
}
if (fn != nullptr) {
- VLOG(jni) << "[Found native code for " << PrettyMethod(m)
+ VLOG(jni) << "[Found native code for " << m->PrettyMethod()
<< " in \"" << library->GetPath() << "\"]";
return fn;
}
}
detail += "No implementation found for ";
- detail += PrettyMethod(m);
+ detail += m->PrettyMethod();
detail += " (tried " + jni_short_name + " and " + jni_long_name + ")";
LOG(ERROR) << detail;
return nullptr;
@@ -471,7 +471,7 @@
}
// TODO: is this useful given that we're about to dump the calling thread's stack?
if (current_method != nullptr) {
- os << "\n from " << PrettyMethod(current_method);
+ os << "\n from " << current_method->PrettyMethod();
}
os << "\n";
self->Dump(os);
@@ -904,7 +904,7 @@
CHECK(m->IsNative());
mirror::Class* c = m->GetDeclaringClass();
// If this is a static method, it could be called before the class has been initialized.
- CHECK(c->IsInitializing()) << c->GetStatus() << " " << PrettyMethod(m);
+ CHECK(c->IsInitializing()) << c->GetStatus() << " " << m->PrettyMethod();
std::string detail;
void* native_method;
Thread* self = Thread::Current();