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/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h
index cbfba12..64b7ecd 100644
--- a/runtime/entrypoints/entrypoint_utils-inl.h
+++ b/runtime/entrypoints/entrypoint_utils-inl.h
@@ -41,10 +41,10 @@
                                        mirror::ArtMethod* method,
                                        Thread* self, bool* slow_path) {
   mirror::Class* klass = method->GetDexCacheResolvedType<false>(type_idx);
-  if (UNLIKELY(klass == NULL)) {
+  if (UNLIKELY(klass == nullptr)) {
     klass = Runtime::Current()->GetClassLinker()->ResolveType(type_idx, method);
     *slow_path = true;
-    if (klass == NULL) {
+    if (klass == nullptr) {
       DCHECK(self->IsExceptionPending());
       return nullptr;  // Failure
     } else {
@@ -526,19 +526,19 @@
                                          mirror::Object* this_object,
                                          mirror::ArtMethod* referrer,
                                          bool access_check, InvokeType type) {
-  if (UNLIKELY(this_object == NULL && type != kStatic)) {
-    return NULL;
+  if (UNLIKELY(this_object == nullptr && type != kStatic)) {
+    return nullptr;
   }
   mirror::ArtMethod* resolved_method =
       referrer->GetDeclaringClass()->GetDexCache()->GetResolvedMethod(method_idx);
-  if (UNLIKELY(resolved_method == NULL)) {
-    return NULL;
+  if (UNLIKELY(resolved_method == nullptr)) {
+    return nullptr;
   }
   if (access_check) {
     // Check for incompatible class change errors and access.
     bool icce = resolved_method->CheckIncompatibleClassChange(type);
     if (UNLIKELY(icce)) {
-      return NULL;
+      return nullptr;
     }
     mirror::Class* methods_class = resolved_method->GetDeclaringClass();
     mirror::Class* referring_class = referrer->GetDeclaringClass();
@@ -546,7 +546,7 @@
                  !referring_class->CanAccessMember(methods_class,
                                                    resolved_method->GetAccessFlags()))) {
       // Potential illegal access, may need to refine the method's class.
-      return NULL;
+      return nullptr;
     }
   }
   if (type == kInterface) {  // Most common form of slow path dispatch.
@@ -606,7 +606,7 @@
 
 inline void UnlockJniSynchronizedMethod(jobject locked, Thread* self) {
   // Save any pending exception over monitor exit call.
-  mirror::Throwable* saved_exception = NULL;
+  mirror::Throwable* saved_exception = nullptr;
   if (UNLIKELY(self->IsExceptionPending())) {
     saved_exception = self->GetException();
     self->ClearException();
@@ -620,7 +620,7 @@
         << self->GetException()->Dump();
   }
   // Restore pending exception.
-  if (saved_exception != NULL) {
+  if (saved_exception != nullptr) {
     self->SetException(saved_exception);
   }
 }
diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc
index 768f505..ce56739 100644
--- a/runtime/entrypoints/entrypoint_utils.cc
+++ b/runtime/entrypoints/entrypoint_utils.cc
@@ -44,9 +44,9 @@
     return nullptr;  // Failure
   }
   mirror::Class* klass = referrer->GetDexCacheResolvedType<false>(type_idx);
-  if (UNLIKELY(klass == NULL)) {  // Not in dex cache so try to resolve
+  if (UNLIKELY(klass == nullptr)) {  // Not in dex cache so try to resolve
     klass = Runtime::Current()->GetClassLinker()->ResolveType(type_idx, referrer);
-    if (klass == NULL) {  // Error
+    if (klass == nullptr) {  // Error
       DCHECK(self->IsExceptionPending());
       return nullptr;  // Failure
     }
@@ -231,13 +231,13 @@
 
   // Build argument array possibly triggering GC.
   soa.Self()->AssertThreadSuspensionIsAllowable();
-  jobjectArray args_jobj = NULL;
+  jobjectArray args_jobj = nullptr;
   const JValue zero;
   int32_t target_sdk_version = Runtime::Current()->GetTargetSdkVersion();
   // Do not create empty arrays unless needed to maintain Dalvik bug compatibility.
   if (args.size() > 0 || (target_sdk_version > 0 && target_sdk_version <= 21)) {
-    args_jobj = soa.Env()->NewObjectArray(args.size(), WellKnownClasses::java_lang_Object, NULL);
-    if (args_jobj == NULL) {
+    args_jobj = soa.Env()->NewObjectArray(args.size(), WellKnownClasses::java_lang_Object, nullptr);
+    if (args_jobj == nullptr) {
       CHECK(soa.Self()->IsExceptionPending());
       return zero;
     }
@@ -249,7 +249,7 @@
         JValue jv;
         jv.SetJ(args.at(i).j);
         mirror::Object* val = BoxPrimitive(Primitive::GetType(shorty[i + 1]), jv);
-        if (val == NULL) {
+        if (val == nullptr) {
           CHECK(soa.Self()->IsExceptionPending());
           return zero;
         }
@@ -270,7 +270,7 @@
 
   // Unbox result and handle error conditions.
   if (LIKELY(!soa.Self()->IsExceptionPending())) {
-    if (shorty[0] == 'V' || (shorty[0] == 'L' && result == NULL)) {
+    if (shorty[0] == 'V' || (shorty[0] == 'L' && result == nullptr)) {
       // Do nothing.
       return zero;
     } else {
@@ -315,7 +315,7 @@
       }
       if (!declares_exception) {
         soa.Self()->ThrowNewWrappedException("Ljava/lang/reflect/UndeclaredThrowableException;",
-                                             NULL);
+                                             nullptr);
       }
     }
     return zero;
diff --git a/runtime/entrypoints/interpreter/interpreter_entrypoints.cc b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc
index 28e19d4..d4844c2 100644
--- a/runtime/entrypoints/interpreter/interpreter_entrypoints.cc
+++ b/runtime/entrypoints/interpreter/interpreter_entrypoints.cc
@@ -47,7 +47,7 @@
       method = shadow_frame->GetMethod();
     }
   }
-  uint16_t arg_offset = (code_item == NULL) ? 0 : code_item->registers_size_ - code_item->ins_size_;
+  uint16_t arg_offset = (code_item == nullptr) ? 0 : code_item->registers_size_ - code_item->ins_size_;
   method->Invoke(self, shadow_frame->GetVRegArgs(arg_offset),
                  (shadow_frame->NumberOfVRegs() - arg_offset) * sizeof(uint32_t),
                  result, method->GetShorty());
diff --git a/runtime/entrypoints/jni/jni_entrypoints.cc b/runtime/entrypoints/jni/jni_entrypoints.cc
index 2752407..a68eeeb 100644
--- a/runtime/entrypoints/jni/jni_entrypoints.cc
+++ b/runtime/entrypoints/jni/jni_entrypoints.cc
@@ -34,15 +34,15 @@
   Locks::mutator_lock_->AssertNotHeld(self);  // We come here as Native.
   ScopedObjectAccess soa(self);
 
-  mirror::ArtMethod* method = self->GetCurrentMethod(NULL);
-  DCHECK(method != NULL);
+  mirror::ArtMethod* method = self->GetCurrentMethod(nullptr);
+  DCHECK(method != nullptr);
 
-  // Lookup symbol address for method, on failure we'll return NULL with an exception set,
+  // Lookup symbol address for method, on failure we'll return null with an exception set,
   // otherwise we return the address of the method we found.
   void* native_code = soa.Vm()->FindCodeForNativeMethod(method);
-  if (native_code == NULL) {
+  if (native_code == nullptr) {
     DCHECK(self->IsExceptionPending());
-    return NULL;
+    return nullptr;
   } else {
     // Register so that future calls don't come here
     method->RegisterNative(native_code, false);
diff --git a/runtime/entrypoints/quick/quick_cast_entrypoints.cc b/runtime/entrypoints/quick/quick_cast_entrypoints.cc
index a6ab69b..37de380 100644
--- a/runtime/entrypoints/quick/quick_cast_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_cast_entrypoints.cc
@@ -22,8 +22,8 @@
 // Assignable test for code, won't throw.  Null and equality tests already performed
 extern "C" uint32_t artIsAssignableFromCode(mirror::Class* klass, mirror::Class* ref_class)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
-  DCHECK(klass != NULL);
-  DCHECK(ref_class != NULL);
+  DCHECK(klass != nullptr);
+  DCHECK(ref_class != nullptr);
   return klass->IsAssignableFrom(ref_class) ? 1 : 0;
 }
 
diff --git a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc
index 54dbd8c..eb1b105 100644
--- a/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_instrumentation_entrypoints.cc
@@ -41,7 +41,7 @@
   bool interpreter_entry = (result == GetQuickToInterpreterBridge());
   instrumentation->PushInstrumentationStackFrame(self, method->IsStatic() ? nullptr : this_object,
                                                  method, lr, interpreter_entry);
-  CHECK(result != NULL) << PrettyMethod(method);
+  CHECK(result != nullptr) << PrettyMethod(method);
   return result;
 }
 
diff --git a/runtime/entrypoints/quick/quick_throw_entrypoints.cc b/runtime/entrypoints/quick/quick_throw_entrypoints.cc
index 9644b98..f22edc1 100644
--- a/runtime/entrypoints/quick/quick_throw_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_throw_entrypoints.cc
@@ -34,10 +34,10 @@
 extern "C" NO_RETURN void artDeliverExceptionFromCode(mirror::Throwable* exception, Thread* self)
     SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
   /*
-   * exception may be NULL, in which case this routine should
+   * exception may be null, in which case this routine should
    * throw NPE.  NOTE: this is a convenience for generated code,
    * which previously did the null check inline and constructed
-   * and threw a NPE if NULL.  This routine responsible for setting
+   * and threw a NPE if null.  This routine responsible for setting
    * exception_ in thread and delivering the exception.
    */
   ScopedQuickEntrypointChecks sqec(self);