Remove mirror:: and ArtMethod deps in utils.{h,cc}
The latest chapter in the ongoing saga of attempting to dump a DEX
file without having to start a whole runtime instance. This episode
finds us removing references to ArtMethod/ArtField/mirror.
One aspect of this change that I would like to call out specfically
is that the utils versions of the "Pretty*" functions all were written
to accept nullptr as an argument. I have split these functions up as
follows:
1) an instance method, such as PrettyClass that obviously requires
this != nullptr.
2) a static method, that behaves the same way as the util method, but
calls the instance method if p != nullptr.
This requires using a full class qualifier for the static methods,
which isn't exactly beautiful. I have tried to remove as many cases
as possible where it was clear p != nullptr.
Bug: 22322814
Test: test-art-host
Change-Id: I21adee3614aa697aa580cd1b86b72d9206e1cb24
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 63de76c..733bd30 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -149,7 +149,7 @@
const char* descriptor = obj->AsClass()->GetDescriptor(&temp);
if (HasInitWithString(self, class_linker, descriptor)) {
- self->ThrowNewException(descriptor, PrettyDescriptor(c).c_str());
+ self->ThrowNewException(descriptor, c->PrettyDescriptor().c_str());
} else {
self->ThrowNewException(descriptor, nullptr);
}
@@ -175,15 +175,16 @@
if (c->GetVerifyError() != nullptr) {
mirror::Object* verify_error = c->GetVerifyError();
if (verify_error->IsClass()) {
- extra = PrettyDescriptor(verify_error->AsClass());
+ extra = mirror::Class::PrettyDescriptor(verify_error->AsClass());
} else {
extra = verify_error->AsThrowable()->Dump();
}
}
- LOG(INFO) << "Rejecting re-init on previously-failed class " << PrettyClass(c) << ": " << extra;
+ LOG(INFO) << "Rejecting re-init on previously-failed class " << c->PrettyClass()
+ << ": " << extra;
}
- CHECK(c->IsErroneous()) << PrettyClass(c) << " " << c->GetStatus();
+ CHECK(c->IsErroneous()) << c->PrettyClass() << " " << c->GetStatus();
Thread* self = Thread::Current();
if (runtime->IsAotCompiler()) {
// At compile time, accurate errors and NCDFE are disabled to speed compilation.
@@ -199,7 +200,7 @@
// the top-level exception must be a NoClassDefFoundError. The potentially already pending
// exception will be a cause.
self->ThrowNewWrappedException("Ljava/lang/NoClassDefFoundError;",
- PrettyDescriptor(c).c_str());
+ c->PrettyDescriptor().c_str());
}
}
}
@@ -294,7 +295,7 @@
*field_offset = MemberOffset(RoundUp(field_offset->Uint32Value(), n));
AddFieldGap(old_offset.Uint32Value(), field_offset->Uint32Value(), gaps);
}
- CHECK(type != Primitive::kPrimNot) << PrettyField(field); // should be primitive types
+ CHECK(type != Primitive::kPrimNot) << field->PrettyField(); // should be primitive types
grouped_and_sorted_fields->pop_front();
if (!gaps->empty() && gaps->top().size >= n) {
FieldGap gap = gaps->top();
@@ -779,11 +780,11 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
if (m->IsRuntimeMethod()) {
mirror::Class* declaring_class = m->GetDeclaringClassUnchecked();
- CHECK(declaring_class == nullptr) << declaring_class << " " << PrettyMethod(m);
+ CHECK(declaring_class == nullptr) << declaring_class << " " << m->PrettyMethod();
} else if (m->IsCopied()) {
- CHECK(m->GetDeclaringClass() != nullptr) << PrettyMethod(m);
+ CHECK(m->GetDeclaringClass() != nullptr) << m->PrettyMethod();
} else if (expected_class != nullptr) {
- CHECK_EQ(m->GetDeclaringClassUnchecked(), expected_class) << PrettyMethod(m);
+ CHECK_EQ(m->GetDeclaringClassUnchecked(), expected_class) << m->PrettyMethod();
}
if (!spaces.empty()) {
bool contains = false;
@@ -1010,7 +1011,7 @@
spaces[i]->GetLiveBitmap()->Walk(CheckTrampolines, &data);
if (data.error) {
ArtMethod* m = data.m;
- LOG(ERROR) << "Found a broken ArtMethod: " << PrettyMethod(m);
+ LOG(ERROR) << "Found a broken ArtMethod: " << ArtMethod::PrettyMethod(m);
*error_msg = "Found an ArtMethod with a bad entrypoint";
return false;
}
@@ -1097,7 +1098,7 @@
DCHECK(dex_file_field != nullptr);
DCHECK(dex_file_name_field != nullptr);
DCHECK(element != nullptr);
- CHECK_EQ(dex_file_field->GetDeclaringClass(), element->GetClass()) << PrettyTypeOf(element);
+ CHECK_EQ(dex_file_field->GetDeclaringClass(), element->GetClass()) << element->PrettyTypeOf();
ObjPtr<mirror::Object> dex_file = dex_file_field->GetObject(element);
if (dex_file == nullptr) {
return nullptr;
@@ -1125,7 +1126,8 @@
while (!ClassLinker::IsBootClassLoader(soa, class_loader)) {
if (soa.Decode<mirror::Class>(WellKnownClasses::dalvik_system_PathClassLoader) !=
class_loader->GetClass()) {
- *error_msg = StringPrintf("Unknown class loader type %s", PrettyTypeOf(class_loader).c_str());
+ *error_msg = StringPrintf("Unknown class loader type %s",
+ class_loader->PrettyTypeOf().c_str());
// Unsupported class loader.
return false;
}
@@ -1213,7 +1215,7 @@
REQUIRES_SHARED(Locks::mutator_lock_, Locks::classlinker_classes_lock_) {
mirror::Class* klass = method->GetDeclaringClass();
if (klass != nullptr && !Runtime::Current()->GetHeap()->ObjectIsInBootImageSpace(klass)) {
- CHECK_EQ(table_->LookupByDescriptor(klass), klass) << PrettyClass(klass);
+ CHECK_EQ(table_->LookupByDescriptor(klass), klass) << mirror::Class::PrettyClass(klass);
}
}
@@ -1415,7 +1417,7 @@
!IsQuickGenericJniStub(code) &&
!IsQuickToInterpreterBridge(code) &&
!m.IsNative()) {
- DCHECK_EQ(code, oat_code) << PrettyMethod(&m);
+ DCHECK_EQ(code, oat_code) << m.PrettyMethod();
}
}
for (ArtMethod& m : klass->GetVirtualMethods(kRuntimePointerSize)) {
@@ -1425,7 +1427,7 @@
!IsQuickGenericJniStub(code) &&
!IsQuickToInterpreterBridge(code) &&
!m.IsNative()) {
- DCHECK_EQ(code, oat_code) << PrettyMethod(&m);
+ DCHECK_EQ(code, oat_code) << m.PrettyMethod();
}
}
}
@@ -1466,7 +1468,7 @@
DCHECK(
space_->GetImageHeader().GetImageSection(ImageHeader::kSectionDexCacheArrays).Contains(
reinterpret_cast<uint8_t*>(strings) - space_->Begin()))
- << "String dex cache array for " << PrettyClass(klass) << " is not in app image";
+ << "String dex cache array for " << klass->PrettyClass() << " is not in app image";
// Dex caches have already been updated, so take the strings pointer from there.
mirror::StringDexCacheType* new_strings = klass->GetDexCache()->GetStrings();
DCHECK_NE(strings, new_strings);
@@ -2270,7 +2272,7 @@
return nullptr;
}
// Return the loaded class. No exceptions should be pending.
- CHECK(klass->IsResolved()) << PrettyClass(klass);
+ CHECK(klass->IsResolved()) << klass->PrettyClass();
self->AssertNoPendingException();
return klass;
}
@@ -2707,7 +2709,7 @@
// Special case to get oat code without overwriting a trampoline.
const void* ClassLinker::GetQuickOatCodeFor(ArtMethod* method) {
- CHECK(method->IsInvokable()) << PrettyMethod(method);
+ CHECK(method->IsInvokable()) << method->PrettyMethod();
if (method->IsProxyMethod()) {
return GetQuickProxyInvokeHandler();
}
@@ -2766,7 +2768,7 @@
}
void ClassLinker::FixupStaticTrampolines(mirror::Class* klass) {
- DCHECK(klass->IsInitialized()) << PrettyDescriptor(klass);
+ DCHECK(klass->IsInitialized()) << klass->PrettyDescriptor();
if (klass->NumDirectMethods() == 0) {
return; // No direct methods => no static methods.
}
@@ -2782,7 +2784,7 @@
CHECK(dex_class_def != nullptr);
const uint8_t* class_data = dex_file.GetClassData(*dex_class_def);
// There should always be class data if there were direct methods.
- CHECK(class_data != nullptr) << PrettyDescriptor(klass);
+ CHECK(class_data != nullptr) << klass->PrettyDescriptor();
ClassDataItemIterator it(dex_file, class_data);
// Skip fields
while (it.HasNextStaticField()) {
@@ -3021,7 +3023,7 @@
}
if (UNLIKELY(num_sfields != it.NumStaticFields()) ||
UNLIKELY(num_ifields != it.NumInstanceFields())) {
- LOG(WARNING) << "Duplicate fields in class " << PrettyDescriptor(klass.Get())
+ LOG(WARNING) << "Duplicate fields in class " << klass->PrettyDescriptor()
<< " (unique static fields: " << num_sfields << "/" << it.NumStaticFields()
<< ", unique instance fields: " << num_ifields << "/" << it.NumInstanceFields() << ")";
// NOTE: Not shrinking the over-allocated sfields/ifields, just setting size.
@@ -3137,7 +3139,7 @@
} else {
if (UNLIKELY((access_flags & kAccConstructor) == 0)) {
LOG(WARNING) << method_name << " didn't have expected constructor access flag in class "
- << PrettyDescriptor(klass.Get()) << " in dex file " << dex_file.GetLocation();
+ << klass->PrettyDescriptor() << " in dex file " << dex_file.GetLocation();
access_flags |= kAccConstructor;
}
}
@@ -3661,8 +3663,8 @@
// If we got this far then we have a hard failure.
std::string error_msg =
StringPrintf("Rejecting class %s that attempts to sub-type erroneous class %s",
- PrettyDescriptor(klass.Get()).c_str(),
- PrettyDescriptor(supertype.Get()).c_str());
+ klass->PrettyDescriptor().c_str(),
+ supertype->PrettyDescriptor().c_str());
LOG(WARNING) << error_msg << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8();
StackHandleScope<1> hs(self);
Handle<mirror::Throwable> cause(hs.NewHandle(self->GetException()));
@@ -3698,8 +3700,9 @@
old_status == mirror::Class::kStatusVerifyingAtRuntime) {
lock.WaitIgnoringInterrupts();
CHECK(klass->IsErroneous() || (klass->GetStatus() > old_status))
- << "Class '" << PrettyClass(klass.Get()) << "' performed an illegal verification state "
- << "transition from " << old_status << " to " << klass->GetStatus();
+ << "Class '" << klass->PrettyClass()
+ << "' performed an illegal verification state transition from " << old_status
+ << " to " << klass->GetStatus();
old_status = klass->GetStatus();
}
@@ -3723,7 +3726,7 @@
mirror::Class::SetStatus(klass, mirror::Class::kStatusVerifying, self);
} else {
CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusRetryVerificationAtRuntime)
- << PrettyClass(klass.Get());
+ << klass->PrettyClass();
CHECK(!Runtime::Current()->IsAotCompiler());
mirror::Class::SetStatus(klass, mirror::Class::kStatusVerifyingAtRuntime, self);
}
@@ -3812,9 +3815,10 @@
if (preverified || verifier_failure != verifier::MethodVerifier::kHardFailure) {
if (!preverified && verifier_failure != verifier::MethodVerifier::kNoFailure) {
- VLOG(class_linker) << "Soft verification failure in class " << PrettyDescriptor(klass.Get())
- << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8()
- << " because: " << error_msg;
+ VLOG(class_linker) << "Soft verification failure in class "
+ << klass->PrettyDescriptor()
+ << " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8()
+ << " because: " << error_msg;
}
self->AssertNoPendingException();
// Make sure all classes referenced by catch blocks are resolved.
@@ -3845,7 +3849,7 @@
}
}
} else {
- VLOG(verifier) << "Verification failed on class " << PrettyDescriptor(klass.Get())
+ VLOG(verifier) << "Verification failed on class " << klass->PrettyDescriptor()
<< " in " << klass->GetDexCache()->GetLocation()->ToModifiedUtf8()
<< " because: " << error_msg;
self->AssertNoPendingException();
@@ -3961,7 +3965,7 @@
}
std::string temp;
LOG(FATAL) << "Unexpected class status: " << oat_file_class_status
- << " " << dex_file.GetLocation() << " " << PrettyClass(klass) << " "
+ << " " << dex_file.GetLocation() << " " << klass->PrettyClass() << " "
<< klass->GetDescriptor(&temp);
UNREACHABLE();
}
@@ -4062,7 +4066,7 @@
// They have as many virtual methods as the array
auto h_methods = hs.NewHandle(soa.Decode<mirror::ObjectArray<mirror::Method>>(methods));
DCHECK_EQ(h_methods->GetClass(), mirror::Method::ArrayClass())
- << PrettyClass(h_methods->GetClass());
+ << mirror::Class::PrettyClass(h_methods->GetClass());
const size_t num_virtual_methods = h_methods->GetLength();
// Create the methods array.
@@ -4142,11 +4146,11 @@
Handle<mirror::String> decoded_name = hs2.NewHandle(soa.Decode<mirror::String>(name));
std::string interfaces_field_name(StringPrintf("java.lang.Class[] %s.interfaces",
decoded_name->ToModifiedUtf8().c_str()));
- CHECK_EQ(PrettyField(klass->GetStaticField(0)), interfaces_field_name);
+ CHECK_EQ(ArtField::PrettyField(klass->GetStaticField(0)), interfaces_field_name);
std::string throws_field_name(StringPrintf("java.lang.Class[][] %s.throws",
decoded_name->ToModifiedUtf8().c_str()));
- CHECK_EQ(PrettyField(klass->GetStaticField(1)), throws_field_name);
+ CHECK_EQ(ArtField::PrettyField(klass->GetStaticField(1)), throws_field_name);
CHECK_EQ(klass.Get()->GetInterfaces(),
soa.Decode<mirror::ObjectArray<mirror::Class>>(interfaces));
@@ -4320,7 +4324,7 @@
return false;
}
- CHECK(klass->IsResolved()) << PrettyClass(klass.Get()) << ": state=" << klass->GetStatus();
+ CHECK(klass->IsResolved()) << klass->PrettyClass() << ": state=" << klass->GetStatus();
if (!klass->IsVerified()) {
VerifyClass(self, klass);
@@ -4334,7 +4338,7 @@
if (self->IsExceptionPending()) {
// Check that it's a VerifyError.
DCHECK_EQ("java.lang.Class<java.lang.VerifyError>",
- PrettyClass(self->GetException()->GetClass()));
+ mirror::Class::PrettyClass(self->GetException()->GetClass()));
} else {
// Check that another thread attempted initialization.
DCHECK_NE(0, klass->GetClinitThreadId());
@@ -4387,7 +4391,7 @@
}
self->AllowThreadSuspension();
- CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusVerified) << PrettyClass(klass.Get())
+ CHECK_EQ(klass->GetStatus(), mirror::Class::kStatusVerified) << klass->PrettyClass()
<< " self.tid=" << self->GetTid() << " clinit.tid=" << klass->GetClinitThreadId();
// From here out other threads may observe that we're initializing and so changes of state
@@ -4412,7 +4416,7 @@
// the super class became erroneous due to initialization.
CHECK(handle_scope_super->IsErroneous() && self->IsExceptionPending())
<< "Super class initialization failed for "
- << PrettyDescriptor(handle_scope_super.Get())
+ << handle_scope_super->PrettyDescriptor()
<< " that has unexpected status " << handle_scope_super->GetStatus()
<< "\nPending exception:\n"
<< (self->GetException() != nullptr ? self->GetException()->Dump() : "");
@@ -4527,7 +4531,8 @@
} else if (Runtime::Current()->IsTransactionAborted()) {
// The exception thrown when the transaction aborted has been caught and cleared
// so we need to throw it again now.
- VLOG(compiler) << "Return from class initializer of " << PrettyDescriptor(klass.Get())
+ VLOG(compiler) << "Return from class initializer of "
+ << mirror::Class::PrettyDescriptor(klass.Get())
<< " without exception while transaction was aborted: re-throw it now.";
Runtime::Current()->ThrowTransactionAbortError(self);
mirror::Class::SetStatus(klass, mirror::Class::kStatusError, self);
@@ -4629,14 +4634,14 @@
// The caller wants an exception, but it was thrown in a
// different thread. Synthesize one here.
ThrowNoClassDefFoundError("<clinit> failed for class %s; see exception in other thread",
- PrettyDescriptor(klass.Get()).c_str());
+ klass->PrettyDescriptor().c_str());
VlogClassInitializationFailure(klass);
return false;
}
if (klass->IsInitialized()) {
return true;
}
- LOG(FATAL) << "Unexpected class status. " << PrettyClass(klass.Get()) << " is "
+ LOG(FATAL) << "Unexpected class status. " << klass->PrettyClass() << " is "
<< klass->GetStatus();
}
UNREACHABLE();
@@ -4653,15 +4658,15 @@
const DexFile::MethodId& method_id = dex_file->GetMethodId(m->GetDexMethodIndex());
const DexFile::ProtoId& proto_id = dex_file->GetMethodPrototype(method_id);
uint16_t return_type_idx = proto_id.return_type_idx_;
- std::string return_type = PrettyType(return_type_idx, *dex_file);
- std::string class_loader = PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader());
+ std::string return_type = dex_file->PrettyType(return_type_idx);
+ std::string class_loader = mirror::Object::PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader());
ThrowWrappedLinkageError(klass.Get(),
"While checking class %s method %s signature against %s %s: "
"Failed to resolve return type %s with %s",
- PrettyDescriptor(klass.Get()).c_str(),
- PrettyMethod(method).c_str(),
+ mirror::Class::PrettyDescriptor(klass.Get()).c_str(),
+ ArtMethod::PrettyMethod(method).c_str(),
super_klass->IsInterface() ? "interface" : "superclass",
- PrettyDescriptor(super_klass.Get()).c_str(),
+ mirror::Class::PrettyDescriptor(super_klass.Get()).c_str(),
return_type.c_str(), class_loader.c_str());
}
@@ -4675,15 +4680,15 @@
DCHECK(Thread::Current()->IsExceptionPending());
DCHECK(!m->IsProxyMethod());
const DexFile* dex_file = m->GetDexFile();
- std::string arg_type = PrettyType(arg_type_idx, *dex_file);
- std::string class_loader = PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader());
+ std::string arg_type = dex_file->PrettyType(arg_type_idx);
+ std::string class_loader = mirror::Object::PrettyTypeOf(m->GetDeclaringClass()->GetClassLoader());
ThrowWrappedLinkageError(klass.Get(),
"While checking class %s method %s signature against %s %s: "
"Failed to resolve arg %u type %s with %s",
- PrettyDescriptor(klass.Get()).c_str(),
- PrettyMethod(method).c_str(),
+ mirror::Class::PrettyDescriptor(klass.Get()).c_str(),
+ ArtMethod::PrettyMethod(method).c_str(),
super_klass->IsInterface() ? "interface" : "superclass",
- PrettyDescriptor(super_klass.Get()).c_str(),
+ mirror::Class::PrettyDescriptor(super_klass.Get()).c_str(),
index, arg_type.c_str(), class_loader.c_str());
}
@@ -4694,10 +4699,10 @@
REQUIRES_SHARED(Locks::mutator_lock_) {
ThrowLinkageError(klass.Get(),
"Class %s method %s resolves differently in %s %s: %s",
- PrettyDescriptor(klass.Get()).c_str(),
- PrettyMethod(method).c_str(),
+ mirror::Class::PrettyDescriptor(klass.Get()).c_str(),
+ ArtMethod::PrettyMethod(method).c_str(),
super_klass->IsInterface() ? "interface" : "superclass",
- PrettyDescriptor(super_klass.Get()).c_str(),
+ mirror::Class::PrettyDescriptor(super_klass.Get()).c_str(),
error_msg.c_str());
}
@@ -4725,9 +4730,9 @@
if (UNLIKELY(other_return_type != return_type.Get())) {
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Return types mismatch: %s(%p) vs %s(%p)",
- PrettyClassAndClassLoader(return_type.Get()).c_str(),
+ return_type->PrettyClassAndClassLoader().c_str(),
return_type.Get(),
- PrettyClassAndClassLoader(other_return_type).c_str(),
+ other_return_type->PrettyClassAndClassLoader().c_str(),
other_return_type));
return false;
}
@@ -4738,7 +4743,7 @@
if (types2 != nullptr && types2->Size() != 0) {
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Type list mismatch with %s",
- PrettyMethod(method2, true).c_str()));
+ method2->PrettyMethod(true).c_str()));
return false;
}
return true;
@@ -4746,7 +4751,7 @@
if (types1->Size() != 0) {
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Type list mismatch with %s",
- PrettyMethod(method2, true).c_str()));
+ method2->PrettyMethod(true).c_str()));
return false;
}
return true;
@@ -4755,7 +4760,7 @@
if (UNLIKELY(num_types != types2->Size())) {
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Type list mismatch with %s",
- PrettyMethod(method2, true).c_str()));
+ method2->PrettyMethod(true).c_str()));
return false;
}
for (uint32_t i = 0; i < num_types; ++i) {
@@ -4780,9 +4785,9 @@
ThrowSignatureMismatch(klass, super_klass, method1,
StringPrintf("Parameter %u type mismatch: %s(%p) vs %s(%p)",
i,
- PrettyClassAndClassLoader(param_type.Get()).c_str(),
+ param_type->PrettyClassAndClassLoader().c_str(),
param_type.Get(),
- PrettyClassAndClassLoader(other_param_type).c_str(),
+ other_param_type->PrettyClassAndClassLoader().c_str(),
other_param_type));
return false;
}
@@ -4848,7 +4853,7 @@
const bool success = InitializeClass(self, c, can_init_fields, can_init_parents);
if (!success) {
if (can_init_fields && can_init_parents) {
- CHECK(self->IsExceptionPending()) << PrettyClass(c.Get());
+ CHECK(self->IsExceptionPending()) << c->PrettyClass();
}
} else {
self->AssertNoPendingException();
@@ -4989,7 +4994,7 @@
if (!klass->IsTemp() || (!init_done_ && klass->GetClassSize() == class_size)) {
// We don't need to retire this class as it has no embedded tables or it was created the
// correct size during class linker initialization.
- CHECK_EQ(klass->GetClassSize(), class_size) << PrettyDescriptor(klass.Get());
+ CHECK_EQ(klass->GetClassSize(), class_size) << klass->PrettyDescriptor();
if (klass->ShouldHaveEmbeddedVTable()) {
klass->PopulateEmbeddedVTable(image_pointer_size_);
@@ -5228,13 +5233,13 @@
LOG(WARNING) << "Incompatible structural change detected: " <<
StringPrintf(
"Structural change of %s is hazardous (%s at compile time, %s at runtime): %s",
- PrettyType(super_class_def->class_idx_, dex_file).c_str(),
+ dex_file.PrettyType(super_class_def->class_idx_).c_str(),
class_oat_file->GetLocation().c_str(),
loaded_super_oat_file->GetLocation().c_str(),
error_msg.c_str());
ThrowIncompatibleClassChangeError(klass.Get(),
"Structural change of %s is hazardous (%s at compile time, %s at runtime): %s",
- PrettyType(super_class_def->class_idx_, dex_file).c_str(),
+ dex_file.PrettyType(super_class_def->class_idx_).c_str(),
class_oat_file->GetLocation().c_str(),
loaded_super_oat_file->GetLocation().c_str(),
error_msg.c_str());
@@ -5261,7 +5266,7 @@
if (super_class_idx == class_def.class_idx_) {
ThrowClassCircularityError(klass.Get(),
"Class %s extends itself",
- PrettyDescriptor(klass.Get()).c_str());
+ klass->PrettyDescriptor().c_str());
return false;
}
@@ -5273,8 +5278,8 @@
// Verify
if (!klass->CanAccess(super_class)) {
ThrowIllegalAccessError(klass.Get(), "Class %s extended by class %s is inaccessible",
- PrettyDescriptor(super_class).c_str(),
- PrettyDescriptor(klass.Get()).c_str());
+ super_class->PrettyDescriptor().c_str(),
+ klass->PrettyDescriptor().c_str());
return false;
}
CHECK(super_class->IsResolved());
@@ -5299,8 +5304,8 @@
// TODO: the RI seemed to ignore this in my testing.
ThrowIllegalAccessError(klass.Get(),
"Interface %s implemented by class %s is inaccessible",
- PrettyDescriptor(interface).c_str(),
- PrettyDescriptor(klass.Get()).c_str());
+ interface->PrettyDescriptor().c_str(),
+ klass->PrettyDescriptor().c_str());
return false;
}
}
@@ -5322,22 +5327,22 @@
}
if (super == nullptr) {
ThrowLinkageError(klass.Get(), "No superclass defined for class %s",
- PrettyDescriptor(klass.Get()).c_str());
+ klass->PrettyDescriptor().c_str());
return false;
}
// Verify
if (super->IsFinal() || super->IsInterface()) {
ThrowIncompatibleClassChangeError(klass.Get(),
"Superclass %s of %s is %s",
- PrettyDescriptor(super).c_str(),
- PrettyDescriptor(klass.Get()).c_str(),
+ super->PrettyDescriptor().c_str(),
+ klass->PrettyDescriptor().c_str(),
super->IsFinal() ? "declared final" : "an interface");
return false;
}
if (!klass->CanAccess(super)) {
ThrowIllegalAccessError(klass.Get(), "Superclass %s is inaccessible to class %s",
- PrettyDescriptor(super).c_str(),
- PrettyDescriptor(klass.Get()).c_str());
+ super->PrettyDescriptor().c_str(),
+ klass->PrettyDescriptor().c_str());
return false;
}
@@ -5362,7 +5367,7 @@
if (init_done_ && super == GetClassRoot(kJavaLangRefReference)) {
ThrowLinkageError(klass.Get(),
"Class %s attempts to subclass java.lang.ref.Reference, which is not allowed",
- PrettyDescriptor(klass.Get()).c_str());
+ klass->PrettyDescriptor().c_str());
return false;
}
@@ -5404,7 +5409,7 @@
REQUIRES_SHARED(Locks::mutator_lock_) :
dex_file_(method->GetDexFile()), mid_(&dex_file_->GetMethodId(method->GetDexMethodIndex())),
name_(nullptr), name_len_(0) {
- DCHECK(!method->IsProxyMethod()) << PrettyMethod(method);
+ DCHECK(!method->IsProxyMethod()) << method->PrettyMethod();
}
const char* GetName() {
@@ -5416,7 +5421,7 @@
bool HasSameNameAndSignature(ArtMethod* other)
REQUIRES_SHARED(Locks::mutator_lock_) {
- DCHECK(!other->IsProxyMethod()) << PrettyMethod(other);
+ DCHECK(!other->IsProxyMethod()) << other->PrettyMethod();
const DexFile* other_dex_file = other->GetDexFile();
const DexFile::MethodId& other_mid = other_dex_file->GetMethodId(other->GetDexMethodIndex());
if (dex_file_ == other_dex_file) {
@@ -5579,7 +5584,7 @@
} else {
DCHECK(super_class->IsAbstract() && !super_class->IsArrayClass());
auto* super_vtable = super_class->GetVTable();
- CHECK(super_vtable != nullptr) << PrettyClass(super_class.Get());
+ CHECK(super_vtable != nullptr) << super_class->PrettyClass();
// We might need to change vtable if we have new virtual methods or new interfaces (since that
// might give us new default methods). See comment above.
if (num_virtual_methods == 0 && super_class->GetIfTableCount() == klass->GetIfTableCount()) {
@@ -5637,14 +5642,14 @@
super_method->GetAccessFlags())) {
if (super_method->IsFinal()) {
ThrowLinkageError(klass.Get(), "Method %s overrides final method in class %s",
- PrettyMethod(virtual_method).c_str(),
+ ArtMethod::PrettyMethod(virtual_method).c_str(),
super_method->GetDeclaringClassDescriptor());
return false;
}
vtable->SetElementPtrSize(j, virtual_method, image_pointer_size_);
virtual_method->SetMethodIndex(j);
} else {
- LOG(WARNING) << "Before Android 4.1, method " << PrettyMethod(virtual_method)
+ LOG(WARNING) << "Before Android 4.1, method " << ArtMethod::PrettyMethod(virtual_method)
<< " would have incorrectly overridden the package-private method in "
<< PrettyDescriptor(super_method->GetDeclaringClassDescriptor());
}
@@ -5691,9 +5696,10 @@
// then.
default_translations->insert(
{j, ClassLinker::MethodTranslation::CreateTranslatedMethod(default_method)});
- VLOG(class_linker) << "Method " << PrettyMethod(super_method)
- << " overridden by default " << PrettyMethod(default_method)
- << " in " << PrettyClass(klass.Get());
+ VLOG(class_linker) << "Method " << super_method->PrettyMethod()
+ << " overridden by default "
+ << default_method->PrettyMethod()
+ << " in " << mirror::Class::PrettyClass(klass.Get());
}
break;
}
@@ -5855,7 +5861,8 @@
// The verifier should have caught the non-public method for dex version 37. Just warn and
// skip it since this is from before default-methods so we don't really need to care that it
// has code.
- LOG(WARNING) << "Interface method " << PrettyMethod(current_method) << " is not public! "
+ LOG(WARNING) << "Interface method " << current_method->PrettyMethod()
+ << " is not public! "
<< "This will be a fatal error in subsequent versions of android. "
<< "Continuing anyway.";
}
@@ -5872,9 +5879,9 @@
iface,
image_pointer_size_)) {
VLOG(class_linker) << "Conflicting default method implementations found: "
- << PrettyMethod(current_method) << " and "
- << PrettyMethod(*out_default_method) << " in class "
- << PrettyClass(klass.Get()) << " conflict.";
+ << current_method->PrettyMethod() << " and "
+ << ArtMethod::PrettyMethod(*out_default_method) << " in class "
+ << klass->PrettyClass() << " conflict.";
*out_default_method = nullptr;
return DefaultMethodSearchResult::kDefaultConflict;
} else {
@@ -5897,18 +5904,20 @@
// We should now finish traversing the graph to find if we have default methods that
// conflict.
} else {
- VLOG(class_linker) << "A default method '" << PrettyMethod(current_method) << "' was "
- << "skipped because it was overridden by an abstract method in a "
- << "subinterface on class '" << PrettyClass(klass.Get()) << "'";
+ VLOG(class_linker) << "A default method '" << current_method->PrettyMethod()
+ << "' was "
+ << "skipped because it was overridden by an abstract method in a "
+ << "subinterface on class '" << klass->PrettyClass() << "'";
}
}
break;
}
}
if (*out_default_method != nullptr) {
- VLOG(class_linker) << "Default method '" << PrettyMethod(*out_default_method) << "' selected "
- << "as the implementation for '" << PrettyMethod(target_method) << "' "
- << "in '" << PrettyClass(klass.Get()) << "'";
+ VLOG(class_linker) << "Default method '" << (*out_default_method)->PrettyMethod()
+ << "' selected "
+ << "as the implementation for '" << target_method->PrettyMethod()
+ << "' in '" << klass->PrettyClass() << "'";
return DefaultMethodSearchResult::kDefaultFound;
} else {
return DefaultMethodSearchResult::kAbstractFound;
@@ -5986,8 +5995,8 @@
}
void ClassLinker::FillIMTAndConflictTables(mirror::Class* klass) {
- DCHECK(klass->ShouldHaveImt()) << PrettyClass(klass);
- DCHECK(!klass->IsTemp()) << PrettyClass(klass);
+ DCHECK(klass->ShouldHaveImt()) << klass->PrettyClass();
+ DCHECK(!klass->IsTemp()) << klass->PrettyClass();
ArtMethod* imt_data[ImTable::kSize];
Runtime* const runtime = Runtime::Current();
ArtMethod* const unimplemented_method = runtime->GetImtUnimplementedMethod();
@@ -6248,8 +6257,8 @@
for (int32_t j = 0; j < ifcount; j++) {
mirror::Class* super_interface = interface->GetIfTable()->GetInterface(j);
DCHECK(ContainsElement(classes_in_iftable, super_interface))
- << "Iftable does not contain " << PrettyClass(super_interface)
- << ", a superinterface of " << PrettyClass(interface);
+ << "Iftable does not contain " << mirror::Class::PrettyClass(super_interface)
+ << ", a superinterface of " << interface->PrettyClass();
}
}
}
@@ -6261,8 +6270,9 @@
mirror::Class* if_b = iftable->GetInterface(j);
// !(if_a <: if_b)
CHECK(!if_b->IsAssignableFrom(if_a))
- << "Bad interface order: " << PrettyClass(if_a) << " (index " << i << ") extends "
- << PrettyClass(if_b) << " (index " << j << ") and so should be after it in the "
+ << "Bad interface order: " << mirror::Class::PrettyClass(if_a) << " (index " << i
+ << ") extends "
+ << if_b->PrettyClass() << " (index " << j << ") and so should be after it in the "
<< "interface list.";
}
}
@@ -6311,7 +6321,7 @@
std::string temp;
ThrowIncompatibleClassChangeError(klass.Get(),
"Class %s implements non-interface class %s",
- PrettyDescriptor(klass.Get()).c_str(),
+ klass->PrettyDescriptor().c_str(),
PrettyDescriptor(interface->GetDescriptor(&temp)).c_str());
return false;
}
@@ -6404,16 +6414,17 @@
CHECK(m != nullptr);
CHECK_EQ(m->GetMethodIndexDuringLinking(), i)
- << PrettyMethod(m) << " has an unexpected method index for its spot in the vtable for class"
- << PrettyClass(klass.Get());
+ << m->PrettyMethod()
+ << " has an unexpected method index for its spot in the vtable for class"
+ << klass->PrettyClass();
ArraySlice<ArtMethod> virtuals = klass->GetVirtualMethodsSliceUnchecked(pointer_size);
auto is_same_method = [m] (const ArtMethod& meth) {
return &meth == m;
};
CHECK((super_vtable_length > i && superclass->GetVTableEntry(i, pointer_size) == m) ||
std::find_if(virtuals.begin(), virtuals.end(), is_same_method) != virtuals.end())
- << PrettyMethod(m) << " does not seem to be owned by current class "
- << PrettyClass(klass.Get()) << " or any of its superclasses!";
+ << m->PrettyMethod() << " does not seem to be owned by current class "
+ << klass->PrettyClass() << " or any of its superclasses!";
}
}
@@ -6441,8 +6452,9 @@
!name_comparator.HasSameNameAndSignature(
other_entry->GetInterfaceMethodIfProxy(pointer_size)))
<< "vtable entries " << i << " and " << j << " are identical for "
- << PrettyClass(klass.Get()) << " in method " << PrettyMethod(vtable_entry) << " and "
- << PrettyMethod(other_entry);
+ << klass->PrettyClass() << " in method "
+ << vtable_entry->PrettyMethod()
+ << " and " << other_entry->PrettyMethod();
}
}
}
@@ -6639,7 +6651,8 @@
self->EndAssertNoThreadSuspension(old_cause);
ThrowIllegalAccessError(klass.Get(),
"Method '%s' implementing interface method '%s' is not public",
- PrettyMethod(vtable_method).c_str(), PrettyMethod(interface_method).c_str());
+ vtable_method->PrettyMethod().c_str(),
+ interface_method->PrettyMethod().c_str());
return false;
} else if (UNLIKELY(vtable_method->IsOverridableByDefaultMethod())) {
// We might have a newer, better, default method for this, so we just skip it. If we
@@ -6698,8 +6711,10 @@
// illegal states, incorrect vtable size, and incorrect or inconsistent iftable entries)
// in this class and any subclasses.
DCHECK(vtable_impl == nullptr || vtable_impl == supers_method)
- << "vtable_impl was " << PrettyMethod(vtable_impl) << " and not 'nullptr' or "
- << PrettyMethod(supers_method) << " as expected. IFTable appears to be corrupt!";
+ << "vtable_impl was " << ArtMethod::PrettyMethod(vtable_impl)
+ << " and not 'nullptr' or "
+ << supers_method->PrettyMethod()
+ << " as expected. IFTable appears to be corrupt!";
vtable_impl = supers_method;
}
}
@@ -6799,7 +6814,7 @@
ArtMethod* miranda_method = FindSameNameAndSignature(interface_name_comparator,
miranda_methods);
if (miranda_method == nullptr) {
- DCHECK(interface_method->IsAbstract()) << PrettyMethod(interface_method);
+ DCHECK(interface_method->IsAbstract()) << interface_method->PrettyMethod();
miranda_method = reinterpret_cast<ArtMethod*>(allocator.Alloc(method_size));
CHECK(miranda_method != nullptr);
// Point the interface table at a phantom slot.
@@ -6831,7 +6846,8 @@
if (has_new_virtuals) {
DCHECK(!is_interface || (default_methods.empty() && miranda_methods.empty()))
<< "Interfaces should only have default-conflict methods appended to them.";
- VLOG(class_linker) << PrettyClass(klass.Get()) << ": miranda_methods=" << miranda_methods.size()
+ VLOG(class_linker) << mirror::Class::PrettyClass(klass.Get()) << ": miranda_methods="
+ << miranda_methods.size()
<< " default_methods=" << default_methods.size()
<< " overriding_default_methods=" << overriding_default_methods.size()
<< " default_conflict_methods=" << default_conflict_methods.size()
@@ -6964,7 +6980,7 @@
auto translated_method_it = move_table.find(new_method);
CHECK(translated_method_it != move_table.end())
<< "We must have a translation for methods added to the classes methods_ array! We "
- << "could not find the ArtMethod added for " << PrettyMethod(new_method);
+ << "could not find the ArtMethod added for " << ArtMethod::PrettyMethod(new_method);
ArtMethod* new_vtable_method = translated_method_it->second;
// Leave the declaring class alone the method's dex_code_item_offset_ and dex_method_index_
// fields are references into the dex file the method was defined in. Since the ArtMethod
@@ -7036,11 +7052,11 @@
for (size_t j = 0, count = iftable->GetMethodArrayCount(i); j < count; ++j) {
auto* method_array = iftable->GetMethodArray(i);
auto* m = method_array->GetElementPtrSize<ArtMethod*>(j, image_pointer_size_);
- DCHECK(m != nullptr) << PrettyClass(klass.Get());
+ DCHECK(m != nullptr) << klass->PrettyClass();
auto it = move_table.find(m);
if (it != move_table.end()) {
auto* new_m = it->second;
- DCHECK(new_m != nullptr) << PrettyClass(klass.Get());
+ DCHECK(new_m != nullptr) << klass->PrettyClass();
method_array->SetElementPtrSize(j, new_m, image_pointer_size_);
}
}
@@ -7068,7 +7084,7 @@
[m] (ArtMethod& meth) {
return &meth == m;
}) != m->GetDeclaringClass()->GetMethods(image_pointer_size_).end())
- << "Obsolete methods " << PrettyMethod(m) << " is in dex cache!";
+ << "Obsolete methods " << m->PrettyMethod() << " is in dex cache!";
}
}
// Put some random garbage in old methods to help find stale pointers.
@@ -7151,12 +7167,12 @@
mirror::Class* super_class = klass->GetSuperClass();
if (super_class != nullptr) {
CHECK(super_class->IsResolved())
- << PrettyClass(klass.Get()) << " " << PrettyClass(super_class);
+ << klass->PrettyClass() << " " << super_class->PrettyClass();
field_offset = MemberOffset(super_class->GetObjectSize());
}
}
- CHECK_EQ(num_fields == 0, fields == nullptr) << PrettyClass(klass.Get());
+ CHECK_EQ(num_fields == 0, fields == nullptr) << klass->PrettyClass();
// we want a relatively stable order so that adding new fields
// minimizes disruption of C++ version such as Class and Method.
@@ -7222,9 +7238,9 @@
if (!is_static && klass->DescriptorEquals("Ljava/lang/ref/Reference;")) {
// We know there are no non-reference fields in the Reference classes, and we know
// that 'referent' is alphabetically last, so this is easy...
- CHECK_EQ(num_reference_fields, num_fields) << PrettyClass(klass.Get());
+ CHECK_EQ(num_reference_fields, num_fields) << klass->PrettyClass();
CHECK_STREQ(fields->At(num_fields - 1).GetName(), "referent")
- << PrettyClass(klass.Get());
+ << klass->PrettyClass();
--num_reference_fields;
}
@@ -7253,11 +7269,11 @@
cur_super = cur_super->GetSuperClass();
}
if (super_class == nullptr) {
- CHECK_EQ(total_reference_instance_fields, 1u) << PrettyDescriptor(klass.Get());
+ CHECK_EQ(total_reference_instance_fields, 1u) << klass->PrettyDescriptor();
} else {
// Check that there is at least num_reference_fields other than Object.class.
CHECK_GE(total_reference_instance_fields, 1u + num_reference_fields)
- << PrettyClass(klass.Get());
+ << klass->PrettyClass();
}
}
if (!klass->IsVariableSize()) {
@@ -7285,8 +7301,8 @@
for (size_t i = 0; i < num_fields; i++) {
ArtField* field = &fields->At(i);
VLOG(class_linker) << "LinkFields: " << (is_static ? "static" : "instance")
- << " class=" << PrettyClass(klass.Get()) << " field=" << PrettyField(field) << " offset="
- << field->GetOffsetDuringLinking();
+ << " class=" << klass->PrettyClass() << " field=" << field->PrettyField()
+ << " offset=" << field->GetOffsetDuringLinking();
if (i != 0) {
ArtField* const prev_field = &fields->At(i - 1);
// NOTE: The field names can be the same. This is not possible in the Java language
@@ -7448,7 +7464,7 @@
}
}
DCHECK((resolved == nullptr) || resolved->IsResolved() || resolved->IsErroneous())
- << PrettyDescriptor(resolved) << " " << resolved->GetStatus();
+ << resolved->PrettyDescriptor() << " " << resolved->GetStatus();
return resolved;
}
@@ -7513,7 +7529,7 @@
if (UNLIKELY(!klass->IsInterface())) {
ThrowIncompatibleClassChangeError(klass,
"Found class %s, but interface was expected",
- PrettyDescriptor(klass).c_str());
+ klass->PrettyDescriptor().c_str());
return nullptr;
} else {
resolved = klass->FindInterfaceMethod(dex_cache.Get(), method_idx, image_pointer_size_);
@@ -7679,7 +7695,8 @@
return nullptr;
}
if (klass->IsInterface()) {
- LOG(FATAL) << "ResolveAmbiguousMethod: unexpected method in interface: " << PrettyClass(klass);
+ LOG(FATAL) << "ResolveAmbiguousMethod: unexpected method in interface: "
+ << klass->PrettyClass();
return nullptr;
}