Fixed slow path for invoke-direct with null this pointer.

Moved the null pointer check until after the class linker tries to
resolve the method on the slow path.

Change-Id: Ie0f9e279a98a7e3a40899fee92337ef454c9a468
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index 92c5e3a..856e877 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -208,7 +208,7 @@
 }
 
 // Slow path method resolution
-AbstractMethod* FindMethodFromCode(uint32_t method_idx, Object* this_object, const AbstractMethod* referrer,
+AbstractMethod* FindMethodFromCode(uint32_t method_idx, Object* this_object, AbstractMethod* referrer,
                            Thread* self, bool access_check, InvokeType type) {
   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
   bool is_direct = type == kStatic || type == kDirect;
@@ -216,6 +216,11 @@
   if (UNLIKELY(resolved_method == NULL)) {
     DCHECK(self->IsExceptionPending());  // Throw exception and unwind.
     return NULL;  // Failure.
+  } else if (UNLIKELY(this_object == NULL && type != kStatic)) {
+    // Maintain interpreter-like semantics where NullPointerException is thrown
+    // after potential NoSuchMethodError from class linker.
+    ThrowNullPointerExceptionForMethodAccess(referrer, method_idx, type);
+    return NULL;  // Failure.
   } else {
     if (!access_check) {
       if (is_direct) {