Early exit for static fixup if no direct methods.
Change-Id: I401746e48259a98fb0c80144ff5310380889b154
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 17a179f..17f8625 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1620,21 +1620,22 @@
}
void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) {
- ClassHelper kh(klass);
- const DexFile::ClassDef* dex_class_def = kh.GetClassDef();
- CHECK(dex_class_def != NULL);
- const DexFile& dex_file = kh.GetDexFile();
- const byte* class_data = dex_file.GetClassData(*dex_class_def);
- if (class_data == NULL) {
- return; // no fields or methods - for example a marker interface
+ if (klass->NumDirectMethods() == 0) {
+ return; // No direct methods => no static methods.
}
Runtime* runtime = Runtime::Current();
if (!runtime->IsStarted() || runtime->UseCompileTimeClassPath()) {
- // OAT file unavailable
- return;
+ return; // OAT file unavailable.
}
+ ClassHelper kh(klass);
+ const DexFile& dex_file = kh.GetDexFile();
+ const DexFile::ClassDef* dex_class_def = kh.GetClassDef();
+ CHECK(dex_class_def != nullptr);
+ const byte* class_data = dex_file.GetClassData(*dex_class_def);
+ // There should always be class data if there were direct methods.
+ CHECK(class_data != nullptr) << PrettyDescriptor(klass);
UniquePtr<const OatFile::OatClass> oat_class(GetOatClass(dex_file, klass->GetDexClassDefIndex()));
- CHECK(oat_class.get() != NULL);
+ CHECK(oat_class.get() != nullptr);
ClassDataItemIterator it(dex_file, class_data);
// Skip fields
while (it.HasNextStaticField()) {
@@ -1643,7 +1644,7 @@
while (it.HasNextInstanceField()) {
it.Next();
}
- // Link the code of methods skipped by LinkCode
+ // Link the code of methods skipped by LinkCode.
for (size_t method_index = 0; it.HasNextDirectMethod(); ++method_index, it.Next()) {
mirror::ArtMethod* method = klass->GetDirectMethod(method_index);
if (!method->IsStatic()) {