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/common_throws.cc b/runtime/common_throws.cc
index 407746f..0808999 100644
--- a/runtime/common_throws.cc
+++ b/runtime/common_throws.cc
@@ -35,7 +35,7 @@
static void AddReferrerLocation(std::ostream& os, mirror::Class* referrer)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- if (referrer != NULL) {
+ if (referrer != nullptr) {
std::string location(referrer->GetLocation());
if (!location.empty()) {
os << " (declaration of '" << PrettyDescriptor(referrer)
@@ -45,10 +45,10 @@
}
static void ThrowException(const char* exception_descriptor,
- mirror::Class* referrer, const char* fmt, va_list* args = NULL)
+ mirror::Class* referrer, const char* fmt, va_list* args = nullptr)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
std::ostringstream msg;
- if (args != NULL) {
+ if (args != nullptr) {
std::string vmsg;
StringAppendV(&vmsg, fmt, *args);
msg << vmsg;
@@ -61,10 +61,10 @@
}
static void ThrowWrappedException(const char* exception_descriptor,
- mirror::Class* referrer, const char* fmt, va_list* args = NULL)
+ mirror::Class* referrer, const char* fmt, va_list* args = nullptr)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
std::ostringstream msg;
- if (args != NULL) {
+ if (args != nullptr) {
std::string vmsg;
StringAppendV(&vmsg, fmt, *args);
msg << vmsg;
@@ -79,7 +79,7 @@
// AbstractMethodError
void ThrowAbstractMethodError(mirror::ArtMethod* method) {
- ThrowException("Ljava/lang/AbstractMethodError;", NULL,
+ ThrowException("Ljava/lang/AbstractMethodError;", nullptr,
StringPrintf("abstract method \"%s\"",
PrettyMethod(method).c_str()).c_str());
}
@@ -87,20 +87,20 @@
// ArithmeticException
void ThrowArithmeticExceptionDivideByZero() {
- ThrowException("Ljava/lang/ArithmeticException;", NULL, "divide by zero");
+ ThrowException("Ljava/lang/ArithmeticException;", nullptr, "divide by zero");
}
// ArrayIndexOutOfBoundsException
void ThrowArrayIndexOutOfBoundsException(int index, int length) {
- ThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", NULL,
+ ThrowException("Ljava/lang/ArrayIndexOutOfBoundsException;", nullptr,
StringPrintf("length=%d; index=%d", length, index).c_str());
}
// ArrayStoreException
void ThrowArrayStoreException(mirror::Class* element_class, mirror::Class* array_class) {
- ThrowException("Ljava/lang/ArrayStoreException;", NULL,
+ ThrowException("Ljava/lang/ArrayStoreException;", nullptr,
StringPrintf("%s cannot be stored in an array of type %s",
PrettyDescriptor(element_class).c_str(),
PrettyDescriptor(array_class).c_str()).c_str());
@@ -109,14 +109,14 @@
// ClassCastException
void ThrowClassCastException(mirror::Class* dest_type, mirror::Class* src_type) {
- ThrowException("Ljava/lang/ClassCastException;", NULL,
+ ThrowException("Ljava/lang/ClassCastException;", nullptr,
StringPrintf("%s cannot be cast to %s",
PrettyDescriptor(src_type).c_str(),
PrettyDescriptor(dest_type).c_str()).c_str());
}
void ThrowClassCastException(const char* msg) {
- ThrowException("Ljava/lang/ClassCastException;", NULL, msg);
+ ThrowException("Ljava/lang/ClassCastException;", nullptr, msg);
}
// ClassCircularityError
@@ -174,7 +174,7 @@
msg << "Final field '" << PrettyField(accessed, false) << "' cannot be written to by method '"
<< PrettyMethod(referrer) << "'";
ThrowException("Ljava/lang/IllegalAccessError;",
- referrer != NULL ? referrer->GetClass() : NULL,
+ referrer != nullptr ? referrer->GetClass() : nullptr,
msg.str().c_str());
}
@@ -188,13 +188,13 @@
// IllegalAccessException
void ThrowIllegalAccessException(const char* msg) {
- ThrowException("Ljava/lang/IllegalAccessException;", NULL, msg);
+ ThrowException("Ljava/lang/IllegalAccessException;", nullptr, msg);
}
// IllegalArgumentException
void ThrowIllegalArgumentException(const char* msg) {
- ThrowException("Ljava/lang/IllegalArgumentException;", NULL, msg);
+ ThrowException("Ljava/lang/IllegalArgumentException;", nullptr, msg);
}
@@ -207,7 +207,7 @@
msg << "The method '" << PrettyMethod(method) << "' was expected to be of type "
<< expected_type << " but instead was found to be of type " << found_type;
ThrowException("Ljava/lang/IncompatibleClassChangeError;",
- referrer != NULL ? referrer->GetClass() : NULL,
+ referrer != nullptr ? referrer->GetClass() : nullptr,
msg.str().c_str());
}
@@ -216,14 +216,14 @@
mirror::ArtMethod* referrer) {
// Referrer is calling interface_method on this_object, however, the interface_method isn't
// implemented by this_object.
- CHECK(this_object != NULL);
+ CHECK(this_object != nullptr);
std::ostringstream msg;
msg << "Class '" << PrettyDescriptor(this_object->GetClass())
<< "' does not implement interface '"
<< PrettyDescriptor(interface_method->GetDeclaringClass())
<< "' in call to '" << PrettyMethod(interface_method) << "'";
ThrowException("Ljava/lang/IncompatibleClassChangeError;",
- referrer != NULL ? referrer->GetClass() : NULL,
+ referrer != nullptr ? referrer->GetClass() : nullptr,
msg.str().c_str());
}
@@ -249,14 +249,14 @@
void ThrowIOException(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowException("Ljava/io/IOException;", NULL, fmt, &args);
+ ThrowException("Ljava/io/IOException;", nullptr, fmt, &args);
va_end(args);
}
void ThrowWrappedIOException(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowWrappedException("Ljava/io/IOException;", NULL, fmt, &args);
+ ThrowWrappedException("Ljava/io/IOException;", nullptr, fmt, &args);
va_end(args);
}
@@ -272,12 +272,12 @@
// NegativeArraySizeException
void ThrowNegativeArraySizeException(int size) {
- ThrowException("Ljava/lang/NegativeArraySizeException;", NULL,
+ ThrowException("Ljava/lang/NegativeArraySizeException;", nullptr,
StringPrintf("%d", size).c_str());
}
void ThrowNegativeArraySizeException(const char* msg) {
- ThrowException("Ljava/lang/NegativeArraySizeException;", NULL, msg);
+ ThrowException("Ljava/lang/NegativeArraySizeException;", nullptr, msg);
}
// NoSuchFieldError
@@ -319,7 +319,7 @@
std::ostringstream msg;
msg << "Attempt to " << (is_read ? "read from" : "write to")
<< " field '" << PrettyField(field, true) << "' on a null object reference";
- ThrowException("Ljava/lang/NullPointerException;", NULL, msg.str().c_str());
+ ThrowException("Ljava/lang/NullPointerException;", nullptr, msg.str().c_str());
}
static void ThrowNullPointerExceptionForMethodAccessImpl(uint32_t method_idx,
@@ -329,7 +329,7 @@
std::ostringstream msg;
msg << "Attempt to invoke " << type << " method '"
<< PrettyMethod(method_idx, dex_file, true) << "' on a null object reference";
- ThrowException("Ljava/lang/NullPointerException;", NULL, msg.str().c_str());
+ ThrowException("Ljava/lang/NullPointerException;", nullptr, msg.str().c_str());
}
void ThrowNullPointerExceptionForMethodAccess(uint32_t method_idx,
@@ -379,7 +379,7 @@
// method is invoked at this location.
mirror::ArtMethod* invoked_method =
verifier::MethodVerifier::FindInvokedMethodAtDexPc(method, throw_dex_pc);
- if (invoked_method != NULL) {
+ if (invoked_method != nullptr) {
// NPE with precise message.
ThrowNullPointerExceptionForMethodAccess(invoked_method, kVirtual);
} else {
@@ -411,7 +411,7 @@
// field is accessed at this location.
ArtField* field =
verifier::MethodVerifier::FindAccessedFieldAtDexPc(method, throw_dex_pc);
- if (field != NULL) {
+ if (field != nullptr) {
// NPE with precise message.
ThrowNullPointerExceptionForFieldAccess(field, true /* read */);
} else {
@@ -443,7 +443,7 @@
// field is accessed at this location.
ArtField* field =
verifier::MethodVerifier::FindAccessedFieldAtDexPc(method, throw_dex_pc);
- if (field != NULL) {
+ if (field != nullptr) {
// NPE with precise message.
ThrowNullPointerExceptionForFieldAccess(field, false /* write */);
} else {
@@ -459,7 +459,7 @@
case Instruction::AGET_BYTE:
case Instruction::AGET_CHAR:
case Instruction::AGET_SHORT:
- ThrowException("Ljava/lang/NullPointerException;", NULL,
+ ThrowException("Ljava/lang/NullPointerException;", nullptr,
"Attempt to read from null array");
break;
case Instruction::APUT:
@@ -469,11 +469,11 @@
case Instruction::APUT_BYTE:
case Instruction::APUT_CHAR:
case Instruction::APUT_SHORT:
- ThrowException("Ljava/lang/NullPointerException;", NULL,
+ ThrowException("Ljava/lang/NullPointerException;", nullptr,
"Attempt to write to null array");
break;
case Instruction::ARRAY_LENGTH:
- ThrowException("Ljava/lang/NullPointerException;", NULL,
+ ThrowException("Ljava/lang/NullPointerException;", nullptr,
"Attempt to get length of null array");
break;
default: {
@@ -481,7 +481,7 @@
// message/logging is so we can improve any cases we've missed in the future.
const DexFile* dex_file =
method->GetDeclaringClass()->GetDexCache()->GetDexFile();
- ThrowException("Ljava/lang/NullPointerException;", NULL,
+ ThrowException("Ljava/lang/NullPointerException;", nullptr,
StringPrintf("Null pointer exception during instruction '%s'",
instr->DumpString(dex_file).c_str()).c_str());
break;
@@ -490,7 +490,7 @@
}
void ThrowNullPointerException(const char* msg) {
- ThrowException("Ljava/lang/NullPointerException;", NULL, msg);
+ ThrowException("Ljava/lang/NullPointerException;", nullptr, msg);
}
// RuntimeException
@@ -498,7 +498,7 @@
void ThrowRuntimeException(const char* fmt, ...) {
va_list args;
va_start(args, fmt);
- ThrowException("Ljava/lang/RuntimeException;", NULL, fmt, &args);
+ ThrowException("Ljava/lang/RuntimeException;", nullptr, fmt, &args);
va_end(args);
}