ART: Allow quickening in the boot image
Update the class linker to accept class status from the boot image
in compiler mode. Update compiler driver to allow quickening for
boot image classes. Update method verifier to accept quickened
instructions in compiler mode when we just want to dump. Update
oatdump to the new verifier API.
Bug: 17316928
(cherry picked from commit 35439baf287b291b67ee406308e17fc6194facbf)
Change-Id: I9ef1bfd78b0d93625b89b3d662131d7d6e5f2903
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 6a6286f..74b262f 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -120,7 +120,7 @@
JNIEnv* env = self->GetJniEnv();
ScopedLocalRef<jthrowable> cause(env, env->ExceptionOccurred());
- CHECK(cause.get() != NULL);
+ CHECK(cause.get() != nullptr);
env->ExceptionClear();
bool is_error = env->IsInstanceOf(cause.get(), WellKnownClasses::java_lang_Error);
@@ -129,7 +129,8 @@
// We only wrap non-Error exceptions; an Error can just be used as-is.
if (!is_error) {
ThrowLocation throw_location = self->GetCurrentLocationForThrow();
- self->ThrowNewWrappedException(throw_location, "Ljava/lang/ExceptionInInitializerError;", NULL);
+ self->ThrowNewWrappedException(throw_location, "Ljava/lang/ExceptionInInitializerError;",
+ nullptr);
}
}
@@ -306,7 +307,7 @@
heap->AllocNonMovableObject<true>(self, nullptr,
mirror::Class::ClassClassSize(),
VoidFunctor()))));
- CHECK(java_lang_Class.Get() != NULL);
+ CHECK(java_lang_Class.Get() != nullptr);
mirror::Class::SetClassClass(java_lang_Class.Get());
java_lang_Class->SetClass(java_lang_Class.Get());
if (kUseBakerOrBrooksReadBarrier) {
@@ -324,7 +325,7 @@
// java_lang_Object comes next so that object_array_class can be created.
Handle<mirror::Class> java_lang_Object(hs.NewHandle(
AllocClass(self, java_lang_Class.Get(), mirror::Object::ClassSize())));
- CHECK(java_lang_Object.Get() != NULL);
+ CHECK(java_lang_Object.Get() != nullptr);
// backfill Object as the super class of Class.
java_lang_Class->SetSuperClass(java_lang_Object.Get());
java_lang_Object->SetStatus(mirror::Class::kStatusLoaded, self);
@@ -405,7 +406,7 @@
// that FindClass can link members.
Handle<mirror::Class> java_lang_reflect_ArtField(hs.NewHandle(
AllocClass(self, java_lang_Class.Get(), mirror::ArtField::ClassSize())));
- CHECK(java_lang_reflect_ArtField.Get() != NULL);
+ CHECK(java_lang_reflect_ArtField.Get() != nullptr);
java_lang_reflect_ArtField->SetObjectSize(mirror::ArtField::InstanceSize());
SetClassRoot(kJavaLangReflectArtField, java_lang_reflect_ArtField.Get());
java_lang_reflect_ArtField->SetStatus(mirror::Class::kStatusResolved, self);
@@ -413,7 +414,7 @@
Handle<mirror::Class> java_lang_reflect_ArtMethod(hs.NewHandle(
AllocClass(self, java_lang_Class.Get(), mirror::ArtMethod::ClassSize())));
- CHECK(java_lang_reflect_ArtMethod.Get() != NULL);
+ CHECK(java_lang_reflect_ArtMethod.Get() != nullptr);
java_lang_reflect_ArtMethod->SetObjectSize(mirror::ArtMethod::InstanceSize());
SetClassRoot(kJavaLangReflectArtMethod, java_lang_reflect_ArtMethod.Get());
java_lang_reflect_ArtMethod->SetStatus(mirror::Class::kStatusResolved, self);
@@ -445,7 +446,7 @@
CHECK_NE(0U, boot_class_path.size());
for (size_t i = 0; i != boot_class_path.size(); ++i) {
const DexFile* dex_file = boot_class_path[i];
- CHECK(dex_file != NULL);
+ CHECK(dex_file != nullptr);
AppendToBootClassPath(self, *dex_file);
}
@@ -522,9 +523,9 @@
// Setup the single, global copy of "iftable".
mirror::Class* java_lang_Cloneable = FindSystemClass(self, "Ljava/lang/Cloneable;");
- CHECK(java_lang_Cloneable != NULL);
+ CHECK(java_lang_Cloneable != nullptr);
mirror::Class* java_io_Serializable = FindSystemClass(self, "Ljava/io/Serializable;");
- CHECK(java_io_Serializable != NULL);
+ CHECK(java_io_Serializable != nullptr);
// We assume that Cloneable/Serializable don't have superinterfaces -- normally we'd have to
// crawl up and explicitly list all of the supers as well.
{
@@ -652,8 +653,8 @@
for (size_t i = 0; i < kClassRootsMax; i++) {
ClassRoot class_root = static_cast<ClassRoot>(i);
mirror::Class* klass = GetClassRoot(class_root);
- CHECK(klass != NULL);
- DCHECK(klass->IsArrayClass() || klass->IsPrimitive() || klass->GetDexCache() != NULL);
+ CHECK(klass != nullptr);
+ DCHECK(klass->IsArrayClass() || klass->IsPrimitive() || klass->GetDexCache() != nullptr);
// note SetClassRoot does additional validation.
// if possible add new checks there to catch errors early
}
@@ -1051,7 +1052,7 @@
uint32_t dex_location_checksum,
const char* oat_location,
std::string* error_msg) {
- std::unique_ptr<OatFile> oat_file(OatFile::Open(oat_location, oat_location, NULL,
+ std::unique_ptr<OatFile> oat_file(OatFile::Open(oat_location, oat_location, nullptr,
!Runtime::Current()->IsCompiler(),
error_msg));
if (oat_file.get() == nullptr) {
@@ -1123,7 +1124,7 @@
error_msgs->push_back(error_msg);
return nullptr;
}
- std::unique_ptr<OatFile> oat_file(OatFile::Open(oat_location, oat_location, NULL,
+ std::unique_ptr<OatFile> oat_file(OatFile::Open(oat_location, oat_location, nullptr,
!Runtime::Current()->IsCompiler(),
&error_msg));
if (oat_file.get() == nullptr) {
@@ -1209,7 +1210,7 @@
const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_location,
&dex_location_checksum);
- if (oat_dex_file == NULL) {
+ if (oat_dex_file == nullptr) {
*error_msg = StringPrintf("oat file '%s' does not contain contents for '%s' with checksum 0x%x",
oat_file->GetLocation().c_str(), dex_location, dex_location_checksum);
for (const OatFile::OatDexFile* oat_dex_file : oat_file->GetOatDexFiles()) {
@@ -1236,7 +1237,7 @@
// If no classes.dex found in dex_location, it has been stripped or is corrupt, assume oat is
// up-to-date. This is the common case in user builds for jar's and apk's in the /system
// directory.
- const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_location, NULL);
+ const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(dex_location, nullptr);
if (oat_dex_file == nullptr) {
*error_msg = StringPrintf("Dex checksum mismatch for location '%s' and failed to find oat "
"dex file '%s': %s", oat_file->GetLocation().c_str(), dex_location,
@@ -1369,7 +1370,7 @@
{
// There is a high probability that these both these oat files map similar/the same address
// spaces so we must scope them like this so they each gets its turn.
- std::unique_ptr<OatFile> odex_oat_file(OatFile::Open(odex_filename, odex_filename, NULL,
+ std::unique_ptr<OatFile> odex_oat_file(OatFile::Open(odex_filename, odex_filename, nullptr,
executable, &odex_error_msg));
if (odex_oat_file.get() != nullptr && CheckOatFile(odex_oat_file.get(), isa,
&odex_checksum_verified,
@@ -1391,7 +1392,7 @@
bool should_patch_cache = false;
bool cache_checksum_verified = false;
if (have_dalvik_cache) {
- std::unique_ptr<OatFile> cache_oat_file(OatFile::Open(cache_filename, cache_filename, NULL,
+ std::unique_ptr<OatFile> cache_oat_file(OatFile::Open(cache_filename, cache_filename, nullptr,
executable, &cache_error_msg));
if (cache_oat_file.get() != nullptr && CheckOatFile(cache_oat_file.get(), isa,
&cache_checksum_verified,
@@ -1468,7 +1469,7 @@
InstructionSet isa,
std::string* error_msg) {
// We open it non-executable
- std::unique_ptr<OatFile> output(OatFile::Open(oat_path, oat_path, NULL, false, error_msg));
+ std::unique_ptr<OatFile> output(OatFile::Open(oat_path, oat_path, nullptr, false, error_msg));
if (output.get() == nullptr) {
return nullptr;
}
@@ -1523,7 +1524,7 @@
LOG(INFO) << "Relocate Oat File: " << command_line;
bool success = Exec(argv, error_msg);
if (success) {
- std::unique_ptr<OatFile> output(OatFile::Open(output_oat, output_oat, NULL,
+ std::unique_ptr<OatFile> output(OatFile::Open(output_oat, output_oat, nullptr,
!Runtime::Current()->IsCompiler(), error_msg));
bool checksum_verified = false;
if (output.get() != nullptr && CheckOatFile(output.get(), isa, &checksum_verified, error_msg)) {
@@ -1632,20 +1633,16 @@
return oat_file;
}
- oat_file = OatFile::Open(oat_location, oat_location, NULL, !Runtime::Current()->IsCompiler(),
- error_msg);
- if (oat_file == NULL) {
- return NULL;
- }
- return oat_file;
+ return OatFile::Open(oat_location, oat_location, nullptr, !Runtime::Current()->IsCompiler(),
+ error_msg);
}
static void InitFromImageInterpretOnlyCallback(mirror::Object* obj, void* arg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
ClassLinker* class_linker = reinterpret_cast<ClassLinker*>(arg);
- DCHECK(obj != NULL);
- DCHECK(class_linker != NULL);
+ DCHECK(obj != nullptr);
+ DCHECK(class_linker != nullptr);
if (obj->IsArtMethod()) {
mirror::ArtMethod* method = obj->AsArtMethod();
@@ -1667,7 +1664,7 @@
gc::Heap* heap = Runtime::Current()->GetHeap();
gc::space::ImageSpace* space = heap->GetImageSpace();
dex_cache_image_class_lookup_required_ = true;
- CHECK(space != NULL);
+ CHECK(space != nullptr);
OatFile& oat_file = GetImageOatFile(space);
CHECK_EQ(oat_file.GetOatHeader().GetImageFileLocationOatChecksum(), 0U);
CHECK_EQ(oat_file.GetOatHeader().GetImageFileLocationOatDataBegin(), 0U);
@@ -1702,10 +1699,10 @@
const std::string& dex_file_location(dex_cache->GetLocation()->ToModifiedUtf8());
const OatFile::OatDexFile* oat_dex_file = oat_file.GetOatDexFile(dex_file_location.c_str(),
nullptr);
- CHECK(oat_dex_file != NULL) << oat_file.GetLocation() << " " << dex_file_location;
+ CHECK(oat_dex_file != nullptr) << oat_file.GetLocation() << " " << dex_file_location;
std::string error_msg;
const DexFile* dex_file = oat_dex_file->OpenDexFile(&error_msg);
- if (dex_file == NULL) {
+ if (dex_file == nullptr) {
LOG(FATAL) << "Failed to open dex file " << dex_file_location
<< " from within oat file " << oat_file.GetLocation()
<< " error '" << error_msg << "'";
@@ -1940,33 +1937,33 @@
hs.NewHandle(down_cast<mirror::DexCache*>(
heap->AllocObject<true>(self, dex_cache_class.Get(), dex_cache_class->GetObjectSize(),
VoidFunctor()))));
- if (dex_cache.Get() == NULL) {
- return NULL;
+ if (dex_cache.Get() == nullptr) {
+ return nullptr;
}
Handle<mirror::String>
location(hs.NewHandle(intern_table_->InternStrong(dex_file.GetLocation().c_str())));
- if (location.Get() == NULL) {
- return NULL;
+ if (location.Get() == nullptr) {
+ return nullptr;
}
Handle<mirror::ObjectArray<mirror::String>>
strings(hs.NewHandle(AllocStringArray(self, dex_file.NumStringIds())));
- if (strings.Get() == NULL) {
- return NULL;
+ if (strings.Get() == nullptr) {
+ return nullptr;
}
Handle<mirror::ObjectArray<mirror::Class>>
types(hs.NewHandle(AllocClassArray(self, dex_file.NumTypeIds())));
- if (types.Get() == NULL) {
- return NULL;
+ if (types.Get() == nullptr) {
+ return nullptr;
}
Handle<mirror::ObjectArray<mirror::ArtMethod>>
methods(hs.NewHandle(AllocArtMethodArray(self, dex_file.NumMethodIds())));
- if (methods.Get() == NULL) {
- return NULL;
+ if (methods.Get() == nullptr) {
+ return nullptr;
}
Handle<mirror::ObjectArray<mirror::ArtField>>
fields(hs.NewHandle(AllocArtFieldArray(self, dex_file.NumFieldIds())));
- if (fields.Get() == NULL) {
- return NULL;
+ if (fields.Get() == nullptr) {
+ return nullptr;
}
dex_cache->Init(&dex_file, location.Get(), strings.Get(), types.Get(), methods.Get(),
fields.Get());
@@ -2010,7 +2007,7 @@
mirror::Class* ClassLinker::EnsureResolved(Thread* self, const char* descriptor,
mirror::Class* klass) {
- DCHECK(klass != NULL);
+ DCHECK(klass != nullptr);
// For temporary classes we must wait for them to be retired.
if (init_done_ && klass->IsTemp()) {
@@ -2070,13 +2067,13 @@
for (size_t i = 0; i != class_path.size(); ++i) {
const DexFile* dex_file = class_path[i];
const DexFile::ClassDef* dex_class_def = dex_file->FindClassDef(descriptor);
- if (dex_class_def != NULL) {
+ if (dex_class_def != nullptr) {
return ClassPathEntry(dex_file, dex_class_def);
}
}
// TODO: remove reinterpret_cast when issue with -std=gnu++0x host issue resolved
- return ClassPathEntry(reinterpret_cast<const DexFile*>(NULL),
- reinterpret_cast<const DexFile::ClassDef*>(NULL));
+ return ClassPathEntry(static_cast<const DexFile*>(nullptr),
+ static_cast<const DexFile::ClassDef*>(nullptr));
}
mirror::Class* ClassLinker::FindClassInPathClassLoader(ScopedObjectAccessAlreadyRunnable& soa,
@@ -2386,7 +2383,7 @@
size_t num_16 = 0;
size_t num_32 = 0;
size_t num_64 = 0;
- if (class_data != NULL) {
+ if (class_data != nullptr) {
for (ClassDataItemIterator it(dex_file, class_data); it.HasNextStaticField(); it.Next()) {
const DexFile::FieldId& field_id = dex_file.GetFieldId(it.GetMemberIndex());
const char* descriptor = dex_file.GetFieldTypeDescriptor(field_id);
@@ -2436,7 +2433,7 @@
uint32_t method_idx) {
const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_idx);
const byte* class_data = dex_file.GetClassData(class_def);
- CHECK(class_data != NULL);
+ CHECK(class_data != nullptr);
ClassDataItemIterator it(dex_file, class_data);
// Skip fields
while (it.HasNextStaticField()) {
@@ -2782,11 +2779,11 @@
const DexFile::ClassDef& dex_class_def,
ConstHandle<mirror::Class> klass,
mirror::ClassLoader* class_loader) {
- CHECK(klass.Get() != NULL);
- CHECK(klass->GetDexCache() != NULL);
+ CHECK(klass.Get() != nullptr);
+ CHECK(klass->GetDexCache() != nullptr);
CHECK_EQ(mirror::Class::kStatusNotReady, klass->GetStatus());
const char* descriptor = dex_file.GetClassDescriptor(dex_class_def);
- CHECK(descriptor != NULL);
+ CHECK(descriptor != nullptr);
klass->SetClass(GetClassRoot(kJavaLangClass));
if (kUseBakerOrBrooksReadBarrier) {
@@ -2797,13 +2794,13 @@
klass->SetAccessFlags(access_flags);
klass->SetClassLoader(class_loader);
DCHECK_EQ(klass->GetPrimitiveType(), Primitive::kPrimNot);
- klass->SetStatus(mirror::Class::kStatusIdx, NULL);
+ klass->SetStatus(mirror::Class::kStatusIdx, nullptr);
klass->SetDexClassDefIndex(dex_file.GetIndexForClassDef(dex_class_def));
klass->SetDexTypeIndex(dex_class_def.class_idx_);
const byte* class_data = dex_file.GetClassData(dex_class_def);
- if (class_data == NULL) {
+ if (class_data == nullptr) {
return; // no fields or methods - for example a marker interface
}
@@ -2830,7 +2827,7 @@
ClassDataItemIterator it(dex_file, class_data);
if (it.NumStaticFields() != 0) {
mirror::ObjectArray<mirror::ArtField>* statics = AllocArtFieldArray(self, it.NumStaticFields());
- if (UNLIKELY(statics == NULL)) {
+ if (UNLIKELY(statics == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return;
}
@@ -2839,7 +2836,7 @@
if (it.NumInstanceFields() != 0) {
mirror::ObjectArray<mirror::ArtField>* fields =
AllocArtFieldArray(self, it.NumInstanceFields());
- if (UNLIKELY(fields == NULL)) {
+ if (UNLIKELY(fields == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return;
}
@@ -2849,7 +2846,7 @@
self->AllowThreadSuspension();
StackHandleScope<1> hs(self);
Handle<mirror::ArtField> sfield(hs.NewHandle(AllocArtField(self)));
- if (UNLIKELY(sfield.Get() == NULL)) {
+ if (UNLIKELY(sfield.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return;
}
@@ -2860,7 +2857,7 @@
self->AllowThreadSuspension();
StackHandleScope<1> hs(self);
Handle<mirror::ArtField> ifield(hs.NewHandle(AllocArtField(self)));
- if (UNLIKELY(ifield.Get() == NULL)) {
+ if (UNLIKELY(ifield.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return;
}
@@ -2873,7 +2870,7 @@
// TODO: append direct methods to class object
mirror::ObjectArray<mirror::ArtMethod>* directs =
AllocArtMethodArray(self, it.NumDirectMethods());
- if (UNLIKELY(directs == NULL)) {
+ if (UNLIKELY(directs == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return;
}
@@ -2883,7 +2880,7 @@
// TODO: append direct methods to class object
mirror::ObjectArray<mirror::ArtMethod>* virtuals =
AllocArtMethodArray(self, it.NumVirtualMethods());
- if (UNLIKELY(virtuals == NULL)) {
+ if (UNLIKELY(virtuals == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return;
}
@@ -2896,7 +2893,7 @@
self->AllowThreadSuspension();
StackHandleScope<1> hs(self);
Handle<mirror::ArtMethod> method(hs.NewHandle(LoadMethod(self, dex_file, it, klass)));
- if (UNLIKELY(method.Get() == NULL)) {
+ if (UNLIKELY(method.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return;
}
@@ -2917,7 +2914,7 @@
self->AllowThreadSuspension();
StackHandleScope<1> hs(self);
Handle<mirror::ArtMethod> method(hs.NewHandle(LoadMethod(self, dex_file, it, klass)));
- if (UNLIKELY(method.Get() == NULL)) {
+ if (UNLIKELY(method.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return;
}
@@ -2946,9 +2943,9 @@
const char* method_name = dex_file.StringDataByIdx(method_id.name_idx_);
mirror::ArtMethod* dst = AllocArtMethod(self);
- if (UNLIKELY(dst == NULL)) {
+ if (UNLIKELY(dst == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
- return NULL;
+ return nullptr;
}
DCHECK(dst->IsArtMethod()) << PrettyDescriptor(dst->GetClass());
@@ -2967,7 +2964,7 @@
// Set finalizable flag on declaring class.
if (strcmp("V", dex_file.GetShorty(method_id.proto_idx_)) == 0) {
// Void return type.
- if (klass->GetClassLoader() != NULL) { // All non-boot finalizer methods are flagged.
+ if (klass->GetClassLoader() != nullptr) { // All non-boot finalizer methods are flagged.
klass->SetFinalizable();
} else {
std::string temp;
@@ -3006,13 +3003,14 @@
void ClassLinker::AppendToBootClassPath(Thread* self, const DexFile& dex_file) {
StackHandleScope<1> hs(self);
Handle<mirror::DexCache> dex_cache(hs.NewHandle(AllocDexCache(self, dex_file)));
- CHECK(dex_cache.Get() != NULL) << "Failed to allocate dex cache for " << dex_file.GetLocation();
+ CHECK(dex_cache.Get() != nullptr) << "Failed to allocate dex cache for "
+ << dex_file.GetLocation();
AppendToBootClassPath(dex_file, dex_cache);
}
void ClassLinker::AppendToBootClassPath(const DexFile& dex_file,
ConstHandle<mirror::DexCache> dex_cache) {
- CHECK(dex_cache.Get() != NULL) << dex_file.GetLocation();
+ CHECK(dex_cache.Get() != nullptr) << dex_file.GetLocation();
boot_class_path_.push_back(&dex_file);
RegisterDexFile(dex_file, dex_cache);
}
@@ -3036,7 +3034,7 @@
void ClassLinker::RegisterDexFileLocked(const DexFile& dex_file,
ConstHandle<mirror::DexCache> dex_cache) {
dex_lock_.AssertExclusiveHeld(Thread::Current());
- CHECK(dex_cache.Get() != NULL) << dex_file.GetLocation();
+ CHECK(dex_cache.Get() != nullptr) << dex_file.GetLocation();
CHECK(dex_cache->GetLocation()->Equals(dex_file.GetLocation()))
<< dex_cache->GetLocation()->ToModifiedUtf8() << " " << dex_file.GetLocation();
dex_caches_.push_back(GcRoot<mirror::DexCache>(dex_cache.Get()));
@@ -3060,7 +3058,8 @@
// get to a suspend point.
StackHandleScope<1> hs(self);
Handle<mirror::DexCache> dex_cache(hs.NewHandle(AllocDexCache(self, dex_file)));
- CHECK(dex_cache.Get() != NULL) << "Failed to allocate dex cache for " << dex_file.GetLocation();
+ CHECK(dex_cache.Get() != nullptr) << "Failed to allocate dex cache for "
+ << dex_file.GetLocation();
{
WriterMutexLock mu(self, dex_lock_);
if (IsDexFileRegisteredLocked(dex_file)) {
@@ -3099,7 +3098,7 @@
LOG(ERROR) << "Registered dex file " << i << " = " << dex_cache->GetDexFile()->GetLocation();
}
LOG(FATAL) << "Failed to find DexCache for DexFile " << location;
- return NULL;
+ return nullptr;
}
void ClassLinker::FixupDexCaches(mirror::ArtMethod* resolution_method) {
@@ -3112,15 +3111,15 @@
mirror::Class* ClassLinker::CreatePrimitiveClass(Thread* self, Primitive::Type type) {
mirror::Class* klass = AllocClass(self, mirror::Class::PrimitiveClassSize());
- if (UNLIKELY(klass == NULL)) {
- return NULL;
+ if (UNLIKELY(klass == nullptr)) {
+ return nullptr;
}
return InitializePrimitiveClass(klass, type);
}
mirror::Class* ClassLinker::InitializePrimitiveClass(mirror::Class* primitive_class,
Primitive::Type type) {
- CHECK(primitive_class != NULL);
+ CHECK(primitive_class != nullptr);
// Must hold lock on object when initializing.
Thread* self = Thread::Current();
StackHandleScope<1> hs(self);
@@ -3131,7 +3130,7 @@
primitive_class->SetStatus(mirror::Class::kStatusInitialized, self);
const char* descriptor = Primitive::Descriptor(type);
mirror::Class* existing = InsertClass(descriptor, primitive_class, Hash(descriptor));
- CHECK(existing == NULL) << "InitPrimitiveClass(" << type << ") failed";
+ CHECK(existing == nullptr) << "InitPrimitiveClass(" << type << ") failed";
return primitive_class;
}
@@ -3147,7 +3146,7 @@
// the right context. It does NOT become the class loader for the
// array class; that always comes from the base element class.
//
-// Returns NULL with an exception raised on failure.
+// Returns nullptr with an exception raised on failure.
mirror::Class* ClassLinker::CreateArrayClass(Thread* self, const char* descriptor,
ConstHandle<mirror::ClassLoader> class_loader) {
// Identify the underlying component type
@@ -3188,7 +3187,7 @@
// other threads.)
if (class_loader.Get() != component_type->GetClassLoader()) {
mirror::Class* new_class = LookupClass(self, descriptor, component_type->GetClassLoader());
- if (new_class != NULL) {
+ if (new_class != nullptr) {
return new_class;
}
}
@@ -3230,7 +3229,7 @@
new_class->SetComponentType(component_type.Get());
}
ObjectLock<mirror::Class> lock(self, new_class); // Must hold lock on object when initializing.
- DCHECK(new_class->GetComponentType() != NULL);
+ DCHECK(new_class->GetComponentType() != nullptr);
mirror::Class* java_lang_Object = GetClassRoot(kJavaLangObject);
new_class->SetSuperClass(java_lang_Object);
new_class->SetVTable(java_lang_Object->GetVTable());
@@ -3310,7 +3309,7 @@
}
std::string printable_type(PrintableChar(type));
ThrowNoClassDefFoundError("Not a primitive type: %s", printable_type.c_str());
- return NULL;
+ return nullptr;
}
mirror::Class* ClassLinker::InsertClass(const char* descriptor, mirror::Class* klass,
@@ -3318,7 +3317,7 @@
if (VLOG_IS_ON(class_linker)) {
mirror::DexCache* dex_cache = klass->GetDexCache();
std::string source;
- if (dex_cache != NULL) {
+ if (dex_cache != nullptr) {
source += " from ";
source += dex_cache->GetLocation()->ToModifiedUtf8();
}
@@ -3327,15 +3326,15 @@
WriterMutexLock mu(Thread::Current(), *Locks::classlinker_classes_lock_);
mirror::Class* existing =
LookupClassFromTableLocked(descriptor, klass->GetClassLoader(), hash);
- if (existing != NULL) {
+ if (existing != nullptr) {
return existing;
}
- if (kIsDebugBuild && !klass->IsTemp() && klass->GetClassLoader() == NULL &&
+ if (kIsDebugBuild && !klass->IsTemp() && klass->GetClassLoader() == nullptr &&
dex_cache_image_class_lookup_required_) {
// Check a class loaded with the system class loader matches one in the image if the class
// is in the image.
existing = LookupClassFromImage(descriptor);
- if (existing != NULL) {
+ if (existing != nullptr) {
CHECK(klass == existing);
}
}
@@ -3344,7 +3343,7 @@
if (log_new_class_table_roots_) {
new_class_roots_.push_back(std::make_pair(hash, GcRoot<mirror::Class>(klass)));
}
- return NULL;
+ return nullptr;
}
mirror::Class* ClassLinker::UpdateClass(const char* descriptor, mirror::Class* klass,
@@ -3362,8 +3361,8 @@
CHECK(!existing->IsResolved()) << descriptor;
CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusResolving) << descriptor;
- for (auto it = class_table_.lower_bound(hash), end = class_table_.end(); it != end && it->first == hash;
- ++it) {
+ for (auto it = class_table_.lower_bound(hash), end = class_table_.end();
+ it != end && it->first == hash; ++it) {
mirror::Class* klass = it->second.Read();
if (klass == existing) {
class_table_.erase(it);
@@ -3412,16 +3411,16 @@
{
ReaderMutexLock mu(self, *Locks::classlinker_classes_lock_);
mirror::Class* result = LookupClassFromTableLocked(descriptor, class_loader, hash);
- if (result != NULL) {
+ if (result != nullptr) {
return result;
}
}
- if (class_loader != NULL || !dex_cache_image_class_lookup_required_) {
- return NULL;
+ if (class_loader != nullptr || !dex_cache_image_class_lookup_required_) {
+ return nullptr;
} else {
// Lookup failed but need to search dex_caches_.
mirror::Class* result = LookupClassFromImage(descriptor);
- if (result != NULL) {
+ if (result != nullptr) {
InsertClass(descriptor, result, hash);
} else {
// Searching the image dex files/caches failed, we don't want to get into this situation
@@ -3456,13 +3455,13 @@
return klass;
}
}
- return NULL;
+ return nullptr;
}
static mirror::ObjectArray<mirror::DexCache>* GetImageDexCaches()
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
gc::space::ImageSpace* image = Runtime::Current()->GetHeap()->GetImageSpace();
- CHECK(image != NULL);
+ CHECK(image != nullptr);
mirror::Object* root = image->GetImageHeader().GetImageRoot(ImageHeader::kDexCaches);
return root->AsObjectArray<mirror::DexCache>();
}
@@ -3482,12 +3481,12 @@
mirror::ObjectArray<mirror::Class>* types = dex_cache->GetResolvedTypes();
for (int32_t j = 0; j < types->GetLength(); j++) {
mirror::Class* klass = types->Get(j);
- if (klass != NULL) {
- DCHECK(klass->GetClassLoader() == NULL);
+ if (klass != nullptr) {
+ DCHECK(klass->GetClassLoader() == nullptr);
const char* descriptor = klass->GetDescriptor(&temp);
size_t hash = Hash(descriptor);
- mirror::Class* existing = LookupClassFromTableLocked(descriptor, NULL, hash);
- if (existing != NULL) {
+ mirror::Class* existing = LookupClassFromTableLocked(descriptor, nullptr, hash);
+ if (existing != nullptr) {
CHECK(existing == klass) << PrettyClassAndClassLoader(existing) << " != "
<< PrettyClassAndClassLoader(klass);
} else {
@@ -3513,13 +3512,13 @@
const DexFile* dex_file = dex_cache->GetDexFile();
// Try binary searching the string/type index.
const DexFile::StringId* string_id = dex_file->FindStringId(descriptor);
- if (string_id != NULL) {
+ if (string_id != nullptr) {
const DexFile::TypeId* type_id =
dex_file->FindTypeId(dex_file->GetIndexForStringId(*string_id));
- if (type_id != NULL) {
+ if (type_id != nullptr) {
uint16_t type_idx = dex_file->GetIndexForTypeId(*type_id);
mirror::Class* klass = dex_cache->GetResolvedType(type_idx);
- if (klass != NULL) {
+ if (klass != nullptr) {
self->EndAssertNoThreadSuspension(old_no_suspend_cause);
return klass;
}
@@ -3527,7 +3526,7 @@
}
}
self->EndAssertNoThreadSuspension(old_no_suspend_cause);
- return NULL;
+ return nullptr;
}
void ClassLinker::LookupClasses(const char* descriptor, std::vector<mirror::Class*>& result) {
@@ -3585,7 +3584,7 @@
// Verify super class.
StackHandleScope<2> hs(self);
Handle<mirror::Class> super(hs.NewHandle(klass->GetSuperClass()));
- if (super.Get() != NULL) {
+ if (super.Get() != nullptr) {
// Acquire lock to prevent races on verifying the super class.
ObjectLock<mirror::Class> lock(self, super);
@@ -3647,7 +3646,7 @@
if (verifier_failure == verifier::MethodVerifier::kNoFailure) {
// Even though there were no verifier failures we need to respect whether the super-class
// was verified or requiring runtime reverification.
- if (super.Get() == NULL || super->IsVerified()) {
+ if (super.Get() == nullptr || super->IsVerified()) {
klass->SetStatus(mirror::Class::kStatusVerified, self);
} else {
CHECK_EQ(super->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime);
@@ -3709,19 +3708,17 @@
// We are compiling an app (not the image).
// Is this an app class? (I.e. not a bootclasspath class)
- if (klass->GetClassLoader() != NULL) {
+ if (klass->GetClassLoader() != nullptr) {
return false;
}
}
const OatFile::OatDexFile* oat_dex_file = FindOpenedOatDexFileForDexFile(dex_file);
- // Make this work with gtests, which do not set up the image properly.
- // TODO: we should clean up gtests to set up the image path properly.
- if (Runtime::Current()->IsCompiler() || (oat_dex_file == nullptr)) {
+ // In case we run without an image there won't be a backing oat file.
+ if (oat_dex_file == nullptr) {
return false;
}
- CHECK(oat_dex_file != NULL) << dex_file.GetLocation() << " " << PrettyClass(klass);
uint16_t class_def_index = klass->GetDexClassDefIndex();
oat_file_class_status = oat_dex_file->GetOatClass(class_def_index).GetStatus();
if (oat_file_class_status == mirror::Class::kStatusVerified ||
@@ -3782,7 +3779,7 @@
mirror::ArtMethod* method) {
// similar to DexVerifier::ScanTryCatchBlocks and dex2oat's ResolveExceptionsForMethod.
const DexFile::CodeItem* code_item = dex_file.GetCodeItem(method->GetCodeItemOffset());
- if (code_item == NULL) {
+ if (code_item == nullptr) {
return; // native or abstract method
}
if (code_item->tries_size_ == 0) {
@@ -3798,7 +3795,7 @@
// unresolved exception types will be ignored by exception delivery
if (iterator.GetHandlerTypeIndex() != DexFile::kDexNoIndex16) {
mirror::Class* exception_type = linker->ResolveType(iterator.GetHandlerTypeIndex(), method);
- if (exception_type == NULL) {
+ if (exception_type == nullptr) {
DCHECK(Thread::Current()->IsExceptionPending());
Thread::Current()->ClearException();
}
@@ -3819,11 +3816,11 @@
StackHandleScope<8> hs(self);
Handle<mirror::Class> klass(hs.NewHandle(
AllocClass(self, GetClassRoot(kJavaLangClass), sizeof(mirror::Class))));
- if (klass.Get() == NULL) {
+ if (klass.Get() == nullptr) {
CHECK(self->IsExceptionPending()); // OOME.
- return NULL;
+ return nullptr;
}
- DCHECK(klass->GetClass() != NULL);
+ DCHECK(klass->GetClass() != nullptr);
klass->SetObjectSize(sizeof(mirror::Proxy));
// Set the class access flags incl. preverified, so we do not try to set the flag on the methods.
klass->SetAccessFlags(kAccClassIsProxy | kAccPublic | kAccFinal | kAccPreverified);
@@ -3837,9 +3834,9 @@
// Instance fields are inherited, but we add a couple of static fields...
{
mirror::ObjectArray<mirror::ArtField>* sfields = AllocArtFieldArray(self, 2);
- if (UNLIKELY(sfields == NULL)) {
+ if (UNLIKELY(sfields == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
- return NULL;
+ return nullptr;
}
klass->SetSFields(sfields);
}
@@ -3887,9 +3884,9 @@
{
mirror::ObjectArray<mirror::ArtMethod>* virtuals = AllocArtMethodArray(self,
num_virtual_methods);
- if (UNLIKELY(virtuals == NULL)) {
+ if (UNLIKELY(virtuals == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
- return NULL;
+ return nullptr;
}
klass->SetVirtualMethods(virtuals);
}
@@ -3913,7 +3910,8 @@
std::string descriptor(GetDescriptorForProxy(klass.Get()));
mirror::Class* new_class = nullptr;
{
- ObjectLock<mirror::Class> resolution_lock(self, klass); // Must hold lock on object when resolved.
+ // Must hold lock on object when resolved.
+ ObjectLock<mirror::Class> resolution_lock(self, klass);
// Link the fields and virtual methods, creating vtable and iftables
Handle<mirror::ObjectArray<mirror::Class> > h_interfaces(
hs.NewHandle(soa.Decode<mirror::ObjectArray<mirror::Class>*>(interfaces)));
@@ -3928,9 +3926,11 @@
klass.Assign(new_class);
CHECK_EQ(interfaces_sfield->GetDeclaringClass(), new_class);
- interfaces_sfield->SetObject<false>(klass.Get(), soa.Decode<mirror::ObjectArray<mirror::Class>*>(interfaces));
+ interfaces_sfield->SetObject<false>(klass.Get(),
+ soa.Decode<mirror::ObjectArray<mirror::Class>*>(interfaces));
CHECK_EQ(throws_sfield->GetDeclaringClass(), new_class);
- throws_sfield->SetObject<false>(klass.Get(), soa.Decode<mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >*>(throws));
+ throws_sfield->SetObject<false>(klass.Get(),
+ soa.Decode<mirror::ObjectArray<mirror::ObjectArray<mirror::Class> >*>(throws));
{
// Lock on klass is released. Lock new class object.
@@ -3973,7 +3973,7 @@
std::string ClassLinker::GetDescriptorForProxy(mirror::Class* proxy_class) {
DCHECK(proxy_class->IsProxyClass());
mirror::String* name = proxy_class->GetName();
- DCHECK(name != NULL);
+ DCHECK(name != nullptr);
return DotToDescriptor(name->ToModifiedUtf8().c_str());
}
@@ -4045,9 +4045,9 @@
// We steal everything from the prototype (such as DexCache, invoke stub, etc.) then specialize
// as necessary
mirror::ArtMethod* method = down_cast<mirror::ArtMethod*>(prototype->Clone(self));
- if (UNLIKELY(method == NULL)) {
+ if (UNLIKELY(method == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
- return NULL;
+ return nullptr;
}
// Set class to be the concrete proxy class and clear the abstract flag, modify exceptions to
@@ -4097,13 +4097,13 @@
if (!can_init_statics) {
// Check if there's a class initializer.
mirror::ArtMethod* clinit = klass->FindClassInitializer();
- if (clinit != NULL) {
+ if (clinit != nullptr) {
return false;
}
// Check if there are encoded static values needing initialization.
if (klass->NumStaticFields() != 0) {
const DexFile::ClassDef* dex_class_def = klass->GetClassDef();
- DCHECK(dex_class_def != NULL);
+ DCHECK(dex_class_def != nullptr);
if (dex_class_def->static_values_off_ != 0) {
return false;
}
@@ -4225,7 +4225,7 @@
<< PrettyDescriptor(handle_scope_super.Get())
<< " that has unexpected status " << handle_scope_super->GetStatus()
<< "\nPending exception:\n"
- << (self->GetException(NULL) != NULL ? self->GetException(NULL)->Dump() : "");
+ << (self->GetException(nullptr) != nullptr ? self->GetException(nullptr)->Dump() : "");
ObjectLock<mirror::Class> lock(self, klass);
// Initialization failed because the super-class is erroneous.
klass->SetStatus(mirror::Class::kStatusError, self);
@@ -4236,7 +4236,7 @@
if (klass->NumStaticFields() > 0) {
const DexFile::ClassDef* dex_class_def = klass->GetClassDef();
- CHECK(dex_class_def != NULL);
+ CHECK(dex_class_def != nullptr);
const DexFile& dex_file = klass->GetDexFile();
StackHandleScope<3> hs(self);
Handle<mirror::ClassLoader> class_loader(hs.NewHandle(klass->GetClassLoader()));
@@ -4263,10 +4263,10 @@
}
mirror::ArtMethod* clinit = klass->FindClassInitializer();
- if (clinit != NULL) {
+ if (clinit != nullptr) {
CHECK(can_init_statics);
JValue result;
- clinit->Invoke(self, NULL, 0, &result, "V");
+ clinit->Invoke(self, nullptr, 0, &result, "V");
}
self->AllowThreadSuspension();
@@ -4480,7 +4480,7 @@
CHECK(!klass->IsResolved());
// Retire the temporary class and create the correctly sized resolved class.
*new_class = klass->CopyOf(self, class_size);
- if (UNLIKELY(*new_class == NULL)) {
+ if (UNLIKELY(*new_class == nullptr)) {
CHECK(self->IsExceptionPending()); // Expect an OOME.
klass->SetStatus(mirror::Class::kStatusError, self);
return false;
@@ -4494,7 +4494,7 @@
FixupTemporaryDeclaringClass(klass.Get(), new_class_h.Get());
mirror::Class* existing = UpdateClass(descriptor, new_class_h.Get(), Hash(descriptor));
- CHECK(existing == NULL || existing == klass.Get());
+ CHECK(existing == nullptr || existing == klass.Get());
// This will notify waiters on temp class that saw the not yet resolved class in the
// class_table_ during EnsureResolved.
@@ -4514,7 +4514,7 @@
uint16_t super_class_idx = class_def.superclass_idx_;
if (super_class_idx != DexFile::kDexNoIndex16) {
mirror::Class* super_class = ResolveType(dex_file, super_class_idx, klass.Get());
- if (super_class == NULL) {
+ if (super_class == nullptr) {
DCHECK(Thread::Current()->IsExceptionPending());
return false;
}
@@ -4529,11 +4529,11 @@
klass->SetSuperClass(super_class);
}
const DexFile::TypeList* interfaces = dex_file.GetInterfacesList(class_def);
- if (interfaces != NULL) {
+ if (interfaces != nullptr) {
for (size_t i = 0; i < interfaces->Size(); i++) {
uint16_t idx = interfaces->GetTypeItem(i).type_idx_;
mirror::Class* interface = ResolveType(dex_file, idx, klass.Get());
- if (interface == NULL) {
+ if (interface == nullptr) {
DCHECK(Thread::Current()->IsExceptionPending());
return false;
}
@@ -4548,7 +4548,7 @@
}
}
// Mark the class as loaded.
- klass->SetStatus(mirror::Class::kStatusLoaded, NULL);
+ klass->SetStatus(mirror::Class::kStatusLoaded, nullptr);
return true;
}
@@ -4556,13 +4556,13 @@
CHECK(!klass->IsPrimitive());
mirror::Class* super = klass->GetSuperClass();
if (klass.Get() == GetClassRoot(kJavaLangObject)) {
- if (super != NULL) {
+ if (super != nullptr) {
ThrowClassFormatError(klass.Get(), "java.lang.Object must not have a superclass");
return false;
}
return true;
}
- if (super == NULL) {
+ if (super == nullptr) {
ThrowLinkageError(klass.Get(), "No superclass defined for class %s",
PrettyDescriptor(klass.Get()).c_str());
return false;
@@ -4603,7 +4603,7 @@
if (kIsDebugBuild) {
// Ensure super classes are fully resolved prior to resolving fields..
- while (super != NULL) {
+ while (super != nullptr) {
CHECK(super->IsResolved());
super = super->GetSuperClass();
}
@@ -4706,7 +4706,7 @@
CHECK_LE(actual_count, max_count);
if (actual_count < max_count) {
vtable.Assign(vtable->CopyOf(self, actual_count));
- if (UNLIKELY(vtable.Get() == NULL)) {
+ if (UNLIKELY(vtable.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return false;
}
@@ -4722,7 +4722,7 @@
StackHandleScope<1> hs(self);
Handle<mirror::ObjectArray<mirror::ArtMethod>>
vtable(hs.NewHandle(AllocArtMethodArray(self, num_virtual_methods)));
- if (UNLIKELY(vtable.Get() == NULL)) {
+ if (UNLIKELY(vtable.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return false;
}
@@ -4760,7 +4760,7 @@
if (ifcount == 0) {
// Class implements no interfaces.
DCHECK_EQ(klass->GetIfTableCount(), 0);
- DCHECK(klass->GetIfTable() == NULL);
+ DCHECK(klass->GetIfTable() == nullptr);
return true;
}
if (ifcount == super_ifcount) {
@@ -4781,7 +4781,7 @@
}
StackHandleScope<5> hs(self);
Handle<mirror::IfTable> iftable(hs.NewHandle(AllocIfTable(self, ifcount)));
- if (UNLIKELY(iftable.Get() == NULL)) {
+ if (UNLIKELY(iftable.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return false;
}
@@ -4799,7 +4799,7 @@
mirror::Class* interface =
interfaces.Get() == nullptr ? mirror::Class::GetDirectInterface(self, klass, i) :
interfaces->Get(i);
- DCHECK(interface != NULL);
+ DCHECK(interface != nullptr);
if (!interface->IsInterface()) {
std::string temp;
ThrowIncompatibleClassChangeError(klass.Get(), "Class %s implements non-interface class %s",
@@ -4840,7 +4840,7 @@
// Shrink iftable in case duplicates were found
if (idx < ifcount) {
iftable.Assign(down_cast<mirror::IfTable*>(iftable->CopyOf(self, idx * mirror::IfTable::kMax)));
- if (UNLIKELY(iftable.Get() == NULL)) {
+ if (UNLIKELY(iftable.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return false;
}
@@ -4859,7 +4859,7 @@
bool imtable_changed = false;
Handle<mirror::ObjectArray<mirror::ArtMethod>> imtable(
hs.NewHandle(AllocArtMethodArray(self, mirror::Class::kImtSize)));
- if (UNLIKELY(imtable.Get() == NULL)) {
+ if (UNLIKELY(imtable.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return false;
}
@@ -4911,7 +4911,7 @@
method_array->Set<false>(j, vtable_mh.Get());
// Place method in imt if entry is empty, place conflict otherwise.
uint32_t imt_index = interface_mh.Get()->GetDexMethodIndex() % mirror::Class::kImtSize;
- if (imtable->Get(imt_index) == NULL) {
+ if (imtable->Get(imt_index) == nullptr) {
imtable->Set<false>(imt_index, vtable_mh.Get());
imtable_changed = true;
} else {
@@ -4932,10 +4932,10 @@
break;
}
}
- if (miranda_method.Get() == NULL) {
+ if (miranda_method.Get() == nullptr) {
// Point the interface table at a phantom slot.
miranda_method.Assign(down_cast<mirror::ArtMethod*>(interface_mh.Get()->Clone(self)));
- if (UNLIKELY(miranda_method.Get() == NULL)) {
+ if (UNLIKELY(miranda_method.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return false;
}
@@ -4951,7 +4951,7 @@
// Fill in empty entries in interface method table with conflict.
mirror::ArtMethod* imt_conflict_method = runtime->GetImtConflictMethod();
for (size_t i = 0; i < mirror::Class::kImtSize; i++) {
- if (imtable->Get(i) == NULL) {
+ if (imtable->Get(i) == nullptr) {
imtable->Set<false>(i, imt_conflict_method);
}
}
@@ -4966,7 +4966,7 @@
} else {
virtuals = klass->GetVirtualMethods()->CopyOf(self, new_method_count);
}
- if (UNLIKELY(virtuals == NULL)) {
+ if (UNLIKELY(virtuals == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return false;
}
@@ -4975,11 +4975,11 @@
StackHandleScope<1> hs(self);
Handle<mirror::ObjectArray<mirror::ArtMethod>> vtable(
hs.NewHandle(klass->GetVTableDuringLinking()));
- CHECK(vtable.Get() != NULL);
+ CHECK(vtable.Get() != nullptr);
int old_vtable_count = vtable->GetLength();
int new_vtable_count = old_vtable_count + miranda_list_size;
vtable.Assign(vtable->CopyOf(self, new_vtable_count));
- if (UNLIKELY(vtable.Get() == NULL)) {
+ if (UNLIKELY(vtable.Get() == nullptr)) {
CHECK(self->IsExceptionPending()); // OOME.
return false;
}
@@ -4997,7 +4997,7 @@
mirror::ObjectArray<mirror::ArtMethod>* vtable = klass->GetVTableDuringLinking();
for (int i = 0; i < vtable->GetLength(); ++i) {
- CHECK(vtable->Get(i) != NULL);
+ CHECK(vtable->Get(i) != nullptr);
}
self->AllowThreadSuspension();
@@ -5006,12 +5006,12 @@
}
bool ClassLinker::LinkInstanceFields(Thread* self, ConstHandle<mirror::Class> klass) {
- CHECK(klass.Get() != NULL);
+ CHECK(klass.Get() != nullptr);
return LinkFields(self, klass, false, nullptr);
}
bool ClassLinker::LinkStaticFields(Thread* self, ConstHandle<mirror::Class> klass, size_t* class_size) {
- CHECK(klass.Get() != NULL);
+ CHECK(klass.Get() != nullptr);
return LinkFields(self, klass, true, class_size);
}
@@ -5063,14 +5063,14 @@
field_offset = MemberOffset(base);
} else {
mirror::Class* super_class = klass->GetSuperClass();
- if (super_class != NULL) {
+ if (super_class != nullptr) {
CHECK(super_class->IsResolved())
<< PrettyClass(klass.Get()) << " " << PrettyClass(super_class);
field_offset = MemberOffset(super_class->GetObjectSize());
}
}
- CHECK_EQ(num_fields == 0, fields == NULL) << PrettyClass(klass.Get());
+ CHECK_EQ(num_fields == 0, fields == nullptr) << PrettyClass(klass.Get());
// we want a relatively stable order so that adding new fields
// minimizes disruption of C++ version such as Class and Method.
@@ -5079,7 +5079,7 @@
"Naked ArtField references in deque");
for (size_t i = 0; i < num_fields; i++) {
mirror::ArtField* f = fields->Get(i);
- CHECK(f != NULL) << PrettyClass(klass.Get());
+ CHECK(f != nullptr) << PrettyClass(klass.Get());
grouped_and_sorted_fields.push_back(f);
}
std::sort(grouped_and_sorted_fields.begin(), grouped_and_sorted_fields.end(),
@@ -5191,7 +5191,7 @@
void ClassLinker::CreateReferenceInstanceOffsets(ConstHandle<mirror::Class> klass) {
uint32_t reference_offsets = 0;
mirror::Class* super_class = klass->GetSuperClass();
- if (super_class != NULL) {
+ if (super_class != nullptr) {
reference_offsets = super_class->GetReferenceInstanceOffsets();
// If our superclass overflowed, we don't stand a chance.
if (reference_offsets == CLASS_WALK_SUPER) {
@@ -5230,7 +5230,7 @@
ConstHandle<mirror::DexCache> dex_cache) {
DCHECK(dex_cache.Get() != nullptr);
mirror::String* resolved = dex_cache->GetResolvedString(string_idx);
- if (resolved != NULL) {
+ if (resolved != nullptr) {
return resolved;
}
uint32_t utf16_length;
@@ -5251,13 +5251,13 @@
mirror::Class* ClassLinker::ResolveType(const DexFile& dex_file, uint16_t type_idx,
ConstHandle<mirror::DexCache> dex_cache,
ConstHandle<mirror::ClassLoader> class_loader) {
- DCHECK(dex_cache.Get() != NULL);
+ DCHECK(dex_cache.Get() != nullptr);
mirror::Class* resolved = dex_cache->GetResolvedType(type_idx);
- if (resolved == NULL) {
+ if (resolved == nullptr) {
Thread* self = Thread::Current();
const char* descriptor = dex_file.StringByTypeIdx(type_idx);
resolved = FindClass(self, descriptor, class_loader);
- if (resolved != NULL) {
+ if (resolved != nullptr) {
// TODO: we used to throw here if resolved's class loader was not the
// boot class loader. This was to permit different classes with the
// same name to be loaded simultaneously by different loaders
@@ -5269,14 +5269,14 @@
StackHandleScope<1> hs(self);
Handle<mirror::Throwable> cause(hs.NewHandle(self->GetException(nullptr)));
if (cause->InstanceOf(GetClassRoot(kJavaLangClassNotFoundException))) {
- DCHECK(resolved == NULL); // No Handle needed to preserve resolved.
+ DCHECK(resolved == nullptr); // No Handle needed to preserve resolved.
self->ClearException();
ThrowNoClassDefFoundError("Failed resolution of: %s", descriptor);
- self->GetException(NULL)->SetCause(cause.Get());
+ self->GetException(nullptr)->SetCause(cause.Get());
}
}
}
- DCHECK((resolved == NULL) || resolved->IsResolved() || resolved->IsErroneous())
+ DCHECK((resolved == nullptr) || resolved->IsResolved() || resolved->IsErroneous())
<< PrettyDescriptor(resolved) << " " << resolved->GetStatus();
return resolved;
}
@@ -5469,7 +5469,7 @@
}
if (resolved == nullptr) {
ThrowNoSuchFieldError(is_static ? "static " : "instance ", klass.Get(), type, name);
- return NULL;
+ return nullptr;
}
}
dex_cache->SetResolvedField(field_idx, resolved);
@@ -5490,16 +5490,16 @@
StackHandleScope<1> hs(self);
Handle<mirror::Class> klass(
hs.NewHandle(ResolveType(dex_file, field_id.class_idx_, dex_cache, class_loader)));
- if (klass.Get() == NULL) {
+ if (klass.Get() == nullptr) {
DCHECK(Thread::Current()->IsExceptionPending());
- return NULL;
+ return nullptr;
}
StringPiece name(dex_file.StringDataByIdx(field_id.name_idx_));
StringPiece type(dex_file.StringDataByIdx(
dex_file.GetTypeId(field_id.type_idx_).descriptor_idx_));
resolved = mirror::Class::FindField(self, klass, name, type);
- if (resolved != NULL) {
+ if (resolved != nullptr) {
dex_cache->SetResolvedField(field_idx, resolved);
} else {
ThrowNoSuchFieldError("", klass.Get(), type, name);
@@ -5565,12 +5565,12 @@
void ClassLinker::SetClassRoot(ClassRoot class_root, mirror::Class* klass) {
DCHECK(!init_done_);
- DCHECK(klass != NULL);
- DCHECK(klass->GetClassLoader() == NULL);
+ DCHECK(klass != nullptr);
+ DCHECK(klass->GetClassLoader() == nullptr);
mirror::ObjectArray<mirror::Class>* class_roots = class_roots_.Read();
- DCHECK(class_roots != NULL);
- DCHECK(class_roots->Get(class_root) == NULL);
+ DCHECK(class_roots != nullptr);
+ DCHECK(class_roots->Get(class_root) == nullptr);
class_roots->Set<false>(class_root, klass);
}