Replace NULL with nullptr

Also fixed some lines that were too long, and a few other minor
details.

Change-Id: I6efba5fb6e03eb5d0a300fddb2a75bf8e2f175cb
diff --git a/runtime/monitor.cc b/runtime/monitor.cc
index 1a80ded..4b41225 100644
--- a/runtime/monitor.cc
+++ b/runtime/monitor.cc
@@ -68,11 +68,11 @@
  * at any given time.
  */
 
-bool (*Monitor::is_sensitive_thread_hook_)() = NULL;
+bool (*Monitor::is_sensitive_thread_hook_)() = nullptr;
 uint32_t Monitor::lock_profiling_threshold_ = 0;
 
 bool Monitor::IsSensitiveThread() {
-  if (is_sensitive_thread_hook_ != NULL) {
+  if (is_sensitive_thread_hook_ != nullptr) {
     return (*is_sensitive_thread_hook_)();
   }
   return false;
@@ -90,9 +90,9 @@
       owner_(owner),
       lock_count_(0),
       obj_(GcRoot<mirror::Object>(obj)),
-      wait_set_(NULL),
+      wait_set_(nullptr),
       hash_code_(hash_code),
-      locking_method_(NULL),
+      locking_method_(nullptr),
       locking_dex_pc_(0),
       monitor_id_(MonitorPool::ComputeMonitorId(this, self)) {
 #ifdef __LP64__
@@ -113,9 +113,9 @@
       owner_(owner),
       lock_count_(0),
       obj_(GcRoot<mirror::Object>(obj)),
-      wait_set_(NULL),
+      wait_set_(nullptr),
       hash_code_(hash_code),
-      locking_method_(NULL),
+      locking_method_(nullptr),
       locking_dex_pc_(0),
       monitor_id_(id) {
 #ifdef __LP64__
@@ -183,9 +183,9 @@
 
 void Monitor::AppendToWaitSet(Thread* thread) {
   DCHECK(owner_ == Thread::Current());
-  DCHECK(thread != NULL);
+  DCHECK(thread != nullptr);
   DCHECK(thread->GetWaitNext() == nullptr) << thread->GetWaitNext();
-  if (wait_set_ == NULL) {
+  if (wait_set_ == nullptr) {
     wait_set_ = thread;
     return;
   }
@@ -200,8 +200,8 @@
 
 void Monitor::RemoveFromWaitSet(Thread *thread) {
   DCHECK(owner_ == Thread::Current());
-  DCHECK(thread != NULL);
-  if (wait_set_ == NULL) {
+  DCHECK(thread != nullptr);
+  if (wait_set_ == nullptr) {
     return;
   }
   if (wait_set_ == thread) {
@@ -211,7 +211,7 @@
   }
 
   Thread* t = wait_set_;
-  while (t->GetWaitNext() != NULL) {
+  while (t->GetWaitNext() != nullptr) {
     if (t->GetWaitNext() == thread) {
       t->SetWaitNext(thread->GetWaitNext());
       thread->SetWaitNext(nullptr);
@@ -253,7 +253,8 @@
     self->SetMonitorEnterObject(GetObject());
     {
       ScopedThreadStateChange tsc(self, kBlocked);  // Change to blocked and give up mutator_lock_.
-      MutexLock mu2(self, monitor_lock_);  // Reacquire monitor_lock_ without mutator_lock_ for Wait.
+      // Reacquire monitor_lock_ without mutator_lock_ for Wait.
+      MutexLock mu2(self, monitor_lock_);
       if (owner_ != nullptr) {  // Did the owner_ give the lock up?
         if (ATRACE_ENABLED()) {
           std::string name;
@@ -311,8 +312,8 @@
 }
 
 static std::string ThreadToString(Thread* thread) {
-  if (thread == NULL) {
-    return "NULL";
+  if (thread == nullptr) {
+    return "nullptr";
   }
   std::ostringstream oss;
   // TODO: alternatively, we could just return the thread's name.
@@ -322,7 +323,7 @@
 
 void Monitor::FailedUnlock(mirror::Object* o, Thread* expected_owner, Thread* found_owner,
                            Monitor* monitor) {
-  Thread* current_owner = NULL;
+  Thread* current_owner = nullptr;
   std::string current_owner_string;
   std::string expected_owner_string;
   std::string found_owner_string;
@@ -331,14 +332,14 @@
     // Acquire thread list lock so threads won't disappear from under us.
     MutexLock mu(Thread::Current(), *Locks::thread_list_lock_);
     // Re-read owner now that we hold lock.
-    current_owner = (monitor != NULL) ? monitor->GetOwner() : NULL;
+    current_owner = (monitor != nullptr) ? monitor->GetOwner() : nullptr;
     // Get short descriptions of the threads involved.
     current_owner_string = ThreadToString(current_owner);
     expected_owner_string = ThreadToString(expected_owner);
     found_owner_string = ThreadToString(found_owner);
   }
-  if (current_owner == NULL) {
-    if (found_owner == NULL) {
+  if (current_owner == nullptr) {
+    if (found_owner == nullptr) {
       ThrowIllegalMonitorStateExceptionF("unlock of unowned monitor on object of type '%s'"
                                          " on thread '%s'",
                                          PrettyTypeOf(o).c_str(),
@@ -352,7 +353,7 @@
                                          expected_owner_string.c_str());
     }
   } else {
-    if (found_owner == NULL) {
+    if (found_owner == nullptr) {
       // Race: originally there was no owner, there is now
       ThrowIllegalMonitorStateExceptionF("unlock of monitor owned by '%s' on object of type '%s'"
                                          " (originally believed to be unowned) on thread '%s'",
@@ -380,14 +381,14 @@
 }
 
 bool Monitor::Unlock(Thread* self) {
-  DCHECK(self != NULL);
+  DCHECK(self != nullptr);
   MutexLock mu(self, monitor_lock_);
   Thread* owner = owner_;
   if (owner == self) {
     // We own the monitor, so nobody else can be in here.
     if (lock_count_ == 0) {
-      owner_ = NULL;
-      locking_method_ = NULL;
+      owner_ = nullptr;
+      locking_method_ = nullptr;
       locking_dex_pc_ = 0;
       // Wake a contender.
       monitor_contenders_.Signal(self);
@@ -406,7 +407,7 @@
 
 void Monitor::Wait(Thread* self, int64_t ms, int32_t ns,
                    bool interruptShouldThrow, ThreadState why) {
-  DCHECK(self != NULL);
+  DCHECK(self != nullptr);
   DCHECK(why == kTimedWaiting || why == kWaiting || why == kSleeping);
 
   monitor_lock_.Lock(self);
@@ -446,9 +447,9 @@
   ++num_waiters_;
   int prev_lock_count = lock_count_;
   lock_count_ = 0;
-  owner_ = NULL;
+  owner_ = nullptr;
   mirror::ArtMethod* saved_method = locking_method_;
-  locking_method_ = NULL;
+  locking_method_ = nullptr;
   uintptr_t saved_dex_pc = locking_dex_pc_;
   locking_dex_pc_ = 0;
 
@@ -465,7 +466,7 @@
     MutexLock mu(self, *self->GetWaitMutex());
 
     // Set wait_monitor_ to the monitor object we will be waiting on. When wait_monitor_ is
-    // non-NULL a notifying or interrupting thread must signal the thread's wait_cond_ to wake it
+    // non-null a notifying or interrupting thread must signal the thread's wait_cond_ to wake it
     // up.
     DCHECK(self->GetWaitMonitor() == nullptr);
     self->SetWaitMonitor(this);
@@ -538,13 +539,13 @@
       self->SetInterruptedLocked(false);
     }
     if (interruptShouldThrow) {
-      self->ThrowNewException("Ljava/lang/InterruptedException;", NULL);
+      self->ThrowNewException("Ljava/lang/InterruptedException;", nullptr);
     }
   }
 }
 
 void Monitor::Notify(Thread* self) {
-  DCHECK(self != NULL);
+  DCHECK(self != nullptr);
   MutexLock mu(self, monitor_lock_);
   // Make sure that we hold the lock.
   if (owner_ != self) {
@@ -552,7 +553,7 @@
     return;
   }
   // Signal the first waiting thread in the wait set.
-  while (wait_set_ != NULL) {
+  while (wait_set_ != nullptr) {
     Thread* thread = wait_set_;
     wait_set_ = thread->GetWaitNext();
     thread->SetWaitNext(nullptr);
@@ -567,7 +568,7 @@
 }
 
 void Monitor::NotifyAll(Thread* self) {
-  DCHECK(self != NULL);
+  DCHECK(self != nullptr);
   MutexLock mu(self, monitor_lock_);
   // Make sure that we hold the lock.
   if (owner_ != self) {
@@ -575,7 +576,7 @@
     return;
   }
   // Signal all threads in the wait set.
-  while (wait_set_ != NULL) {
+  while (wait_set_ != nullptr) {
     Thread* thread = wait_set_;
     wait_set_ = thread->GetWaitNext();
     thread->SetWaitNext(nullptr);
@@ -625,7 +626,7 @@
       obj->SetLockWord(new_lw, false);
       VLOG(monitor) << "Deflated" << obj << " to empty lock word";
     }
-    // The monitor is deflated, mark the object as nullptr so that we know to delete it during the
+    // The monitor is deflated, mark the object as null so that we know to delete it during the
     // next GC.
     monitor->obj_ = GcRoot<mirror::Object>(nullptr);
   }
@@ -697,8 +698,8 @@
 }
 
 mirror::Object* Monitor::MonitorEnter(Thread* self, mirror::Object* obj) {
-  DCHECK(self != NULL);
-  DCHECK(obj != NULL);
+  DCHECK(self != nullptr);
+  DCHECK(obj != nullptr);
   obj = FakeLock(obj);
   uint32_t thread_id = self->GetThreadId();
   size_t contention_count = 0;
@@ -772,8 +773,8 @@
 }
 
 bool Monitor::MonitorExit(Thread* self, mirror::Object* obj) {
-  DCHECK(self != NULL);
-  DCHECK(obj != NULL);
+  DCHECK(self != nullptr);
+  DCHECK(obj != nullptr);
   obj = FakeUnlock(obj);
   StackHandleScope<1> hs(self);
   Handle<mirror::Object> h_obj(hs.NewHandle(obj));
@@ -979,11 +980,11 @@
   // This is used to implement JDWP's ThreadReference.CurrentContendedMonitor, and has a bizarre
   // definition of contended that includes a monitor a thread is trying to enter...
   mirror::Object* result = thread->GetMonitorEnterObject();
-  if (result == NULL) {
+  if (result == nullptr) {
     // ...but also a monitor that the thread is waiting on.
     MutexLock mu(Thread::Current(), *thread->GetWaitMutex());
     Monitor* monitor = thread->GetWaitMonitor();
-    if (monitor != NULL) {
+    if (monitor != nullptr) {
       result = monitor->GetObject();
     }
   }
@@ -993,7 +994,7 @@
 void Monitor::VisitLocks(StackVisitor* stack_visitor, void (*callback)(mirror::Object*, void*),
                          void* callback_context, bool abort_on_failure) {
   mirror::ArtMethod* m = stack_visitor->GetMethod();
-  CHECK(m != NULL);
+  CHECK(m != nullptr);
 
   // Native methods are an easy special case.
   // TODO: use the JNI implementation's table of explicit MonitorEnter calls and dump those too.
@@ -1013,7 +1014,7 @@
 
   // Is there any reason to believe there's any synchronization in this method?
   const DexFile::CodeItem* code_item = m->GetCodeItem();
-  CHECK(code_item != NULL) << PrettyMethod(m);
+  CHECK(code_item != nullptr) << PrettyMethod(m);
   if (code_item->tries_size_ == 0) {
     return;  // No "tries" implies no synchronization, so no held locks to report.
   }
@@ -1088,13 +1089,13 @@
 void Monitor::TranslateLocation(mirror::ArtMethod* method, uint32_t dex_pc,
                                 const char** source_file, uint32_t* line_number) const {
   // If method is null, location is unknown
-  if (method == NULL) {
+  if (method == nullptr) {
     *source_file = "";
     *line_number = 0;
     return;
   }
   *source_file = method->GetDeclaringClassSourceFile();
-  if (*source_file == NULL) {
+  if (*source_file == nullptr) {
     *source_file = "";
   }
   *line_number = method->GetLineNumFromDexPC(dex_pc);
@@ -1103,7 +1104,7 @@
 uint32_t Monitor::GetOwnerThreadId() {
   MutexLock mu(Thread::Current(), monitor_lock_);
   Thread* owner = owner_;
-  if (owner != NULL) {
+  if (owner != nullptr) {
     return owner->GetThreadId();
   } else {
     return ThreadList::kInvalidThreadId;
@@ -1185,7 +1186,7 @@
   if (Monitor::Deflate(args->self, object)) {
     DCHECK_NE(object->GetLockWord(true).GetState(), LockWord::kFatLocked);
     ++args->deflate_count;
-    // If we deflated, return nullptr so that the monitor gets removed from the array.
+    // If we deflated, return null so that the monitor gets removed from the array.
     return nullptr;
   }
   return object;  // Monitor was not deflated.
@@ -1198,7 +1199,7 @@
   return args.deflate_count;
 }
 
-MonitorInfo::MonitorInfo(mirror::Object* obj) : owner_(NULL), entry_count_(0) {
+MonitorInfo::MonitorInfo(mirror::Object* obj) : owner_(nullptr), entry_count_(0) {
   DCHECK(obj != nullptr);
   LockWord lock_word = obj->GetLockWord(true);
   switch (lock_word.GetState()) {
@@ -1217,7 +1218,7 @@
       Monitor* mon = lock_word.FatLockMonitor();
       owner_ = mon->owner_;
       entry_count_ = 1 + mon->lock_count_;
-      for (Thread* waiter = mon->wait_set_; waiter != NULL; waiter = waiter->GetWaitNext()) {
+      for (Thread* waiter = mon->wait_set_; waiter != nullptr; waiter = waiter->GetWaitNext()) {
         waiters_.push_back(waiter);
       }
       break;