Small change to make CompilerTest.CompileDexLibCore pass

Change-Id: Id5989a369acec41faae4bbd949b8979962384b2c
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 0df0cb7..01e283e 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -2114,10 +2114,10 @@
 
   const char* name = dex_file.dexStringById(method_id.name_idx_);
   std::string signature(dex_file.CreateMethodDescriptor(method_id.proto_idx_, NULL));
-  if (klass->IsInterface()) {
-    resolved = klass->FindInterfaceMethod(name, signature);
-  } else if (is_direct) {
+  if (is_direct) {
     resolved = klass->FindDirectMethod(name, signature);
+  } else if (klass->IsInterface()) {
+    resolved = klass->FindInterfaceMethod(name, signature);
   } else {
     resolved = klass->FindVirtualMethod(name, signature);
   }
diff --git a/src/compiler_test.cc b/src/compiler_test.cc
index e232858..5766a4f 100644
--- a/src/compiler_test.cc
+++ b/src/compiler_test.cc
@@ -56,7 +56,7 @@
   }
 };
 
-// TODO renenable when compiler can handle libcore
+// Disabled due to 10 second runtime on host
 TEST_F(CompilerTest, DISABLED_CompileDexLibCore) {
   Compiler compiler;
   compiler.CompileAll(NULL);
@@ -67,22 +67,27 @@
   EXPECT_EQ(dex->NumStringIds(), dex_cache->NumStrings());
   for (size_t i = 0; i < dex_cache->NumStrings(); i++) {
     const String* string = dex_cache->GetResolvedString(i);
-    EXPECT_TRUE(string != NULL);
+    EXPECT_TRUE(string != NULL) << "string_idx=" << i;
   }
   EXPECT_EQ(dex->NumTypeIds(), dex_cache->NumResolvedTypes());
   for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) {
     Class* type = dex_cache->GetResolvedType(i);
-    EXPECT_TRUE(type != NULL);
+    EXPECT_TRUE(type != NULL) << "type_idx=" << i
+                              << " " << dex->GetTypeDescriptor(dex->GetTypeId(i));
   }
   EXPECT_EQ(dex->NumMethodIds(), dex_cache->NumResolvedMethods());
   for (size_t i = 0; i < dex_cache->NumResolvedMethods(); i++) {
     Method* method = dex_cache->GetResolvedMethod(i);
-    EXPECT_TRUE(method != NULL);
+    EXPECT_TRUE(method != NULL) << "method_idx=" << i
+                                << " " << dex->GetMethodClassDescriptor(dex->GetMethodId(i))
+                                << " " << dex->GetMethodName(dex->GetMethodId(i));
   }
   EXPECT_EQ(dex->NumFieldIds(), dex_cache->NumResolvedFields());
   for (size_t i = 0; i < dex_cache->NumResolvedFields(); i++) {
     Field* field = dex_cache->GetResolvedField(i);
-    EXPECT_TRUE(field != NULL);
+    EXPECT_TRUE(field != NULL) << "field_idx=" << i
+                               << " " << dex->GetFieldClassDescriptor(dex->GetFieldId(i))
+                               << " " << dex->GetFieldName(dex->GetFieldId(i));
   }
 
   // TODO check Class::IsVerified for all classes
@@ -93,8 +98,13 @@
   CodeAndDirectMethods* code_and_direct_methods = dex_cache->GetCodeAndDirectMethods();
   for (size_t i = 0; i < dex_cache->NumCodeAndDirectMethods(); i++) {
     Method* method = dex_cache->GetResolvedMethod(i);
-    EXPECT_EQ(method->GetCode(), code_and_direct_methods->GetResolvedCode(i));
-    EXPECT_EQ(method,            code_and_direct_methods->GetResolvedMethod(i));
+    if (method->IsDirect()) {
+      EXPECT_EQ(method->GetCode(), code_and_direct_methods->GetResolvedCode(i));
+      EXPECT_EQ(method,            code_and_direct_methods->GetResolvedMethod(i));
+    } else {
+      EXPECT_EQ(0U, code_and_direct_methods->GetResolvedCode(i));
+      EXPECT_TRUE(code_and_direct_methods->GetResolvedMethod(i) == NULL);
+    }
   }
 }
 
diff --git a/src/dex_file.h b/src/dex_file.h
index 98e79a7..cf0bf20 100644
--- a/src/dex_file.h
+++ b/src/dex_file.h
@@ -428,6 +428,17 @@
     return dexStringById(field_id.name_idx_);
   }
 
+  // Returns the class descriptor string of a method id.
+  const char* GetMethodClassDescriptor(const MethodId& method_id) const {
+    const DexFile::TypeId& type_id = GetTypeId(method_id.class_idx_);
+    return GetTypeDescriptor(type_id);
+  }
+
+  // Returns the name of a method id.
+  const char* GetMethodName(const MethodId& method_id) const {
+    return dexStringById(method_id.name_idx_);
+  }
+
   // Returns the StringId at the specified index.
   const StringId& GetStringId(uint32_t idx) const {
     CHECK_LT(idx, NumStringIds());