Update null pointer exception message to print out the method

Let's add the method in the logging string for context when debugging failures. This should help developers debug more quickly.

Bug: 217171086
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Change-Id: I1aadeaa536f58a22dccaf6f1c783df23c9430c7a
diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc
index c6e7cfb..17a0a8a 100644
--- a/runtime/common_throws.cc
+++ b/runtime/common_throws.cc
@@ -23,6 +23,7 @@
 
 #include "art_field-inl.h"
 #include "art_method-inl.h"
+#include "art_method.h"
 #include "class_linker-inl.h"
 #include "debug_print.h"
 #include "dex/dex_file-inl.h"
@@ -406,10 +407,11 @@
 
 // NullPointerException
 
-void ThrowNullPointerExceptionForFieldAccess(ArtField* field, bool is_read) {
+void ThrowNullPointerExceptionForFieldAccess(ArtField* field, ArtMethod* method, bool is_read) {
   std::ostringstream msg;
-  msg << "Attempt to " << (is_read ? "read from" : "write to")
-      << " field '" << ArtField::PrettyField(field, true) << "' on a null object reference";
+  msg << "Attempt to " << (is_read ? "read from" : "write to") << " field '"
+      << ArtField::PrettyField(field) << "' on a null object reference in method '"
+      << ArtMethod::PrettyMethod(method) << "'";
   ThrowException("Ljava/lang/NullPointerException;", nullptr, msg.str().c_str());
 }
 
@@ -585,7 +587,7 @@
       ArtField* field =
           Runtime::Current()->GetClassLinker()->ResolveField(instr.VRegC_22c(), method, false);
       Thread::Current()->ClearException();  // Resolution may fail, ignore.
-      ThrowNullPointerExceptionForFieldAccess(field, /* is_read= */ true);
+      ThrowNullPointerExceptionForFieldAccess(field, method, /* is_read= */ true);
       break;
     }
     case Instruction::IPUT:
@@ -598,7 +600,7 @@
       ArtField* field = Runtime::Current()->GetClassLinker()->ResolveField(
           instr.VRegC_22c(), method, /* is_static= */ false);
       Thread::Current()->ClearException();  // Resolution may fail, ignore.
-      ThrowNullPointerExceptionForFieldAccess(field, /* is_read= */ false);
+      ThrowNullPointerExceptionForFieldAccess(field, method, /* is_read= */ false);
       break;
     }
     case Instruction::AGET: