bool ArtClassDefinition::IsModified() const { // RedefineClasses calls always are 'modified' since they need to change the current_dex_file of // the class. if (redefined_) { returntrue;
}
// Check to see if any change has taken place. if (current_dex_file_.data() == dex_data_.data()) { // no change at all. returnfalse;
}
// Check if the dex file we want to set is the same as the current one. // Unfortunately we need to do this check even if no modifications have been done since it could // be that agents were removed in the mean-time so we still have a different dex file. The dex // checksum means this is likely to be fairly fast. return current_dex_file_.size() != dex_data_.size() ||
memcmp(current_dex_file_.data(), dex_data_.data(), current_dex_file_.size()) != 0;
}
jvmtiError ArtClassDefinition::Init(art::Thread* self, jclass klass) {
jvmtiError res = InitCommon(self, klass); if (res != OK) { return res;
}
art::ScopedObjectAccess soa(self);
art::StackHandleScope<1> hs(self);
art::Handle<art::mirror::Class> m_klass(hs.NewHandle(self->DecodeJObject(klass)->AsClass()));
art::ObjPtr<art::mirror::ClassExt> ext(m_klass->GetExtData()); if (!ext.IsNull()) {
art::ObjPtr<art::mirror::Object> orig_dex(ext->GetOriginalDexFile()); if (!orig_dex.IsNull()) { if (orig_dex->IsArrayInstance()) { // An array instance means the original-dex-file is from a redefineClasses which cannot have any // compact dex, so it's fine to use directly.
art::ObjPtr<art::mirror::ByteArray> byte_array(orig_dex->AsByteArray());
dex_data_memory_.resize(byte_array->GetLength());
memcpy(dex_data_memory_.data(), byte_array->GetData(), dex_data_memory_.size());
dex_data_ = art::ArrayRef<constunsignedchar>(dex_data_memory_);
if (orig_dex->IsDexCache()) {
res = Init(*orig_dex->AsDexCache()->GetDexFile()); if (res != OK) { return res;
}
} else {
DCHECK(orig_dex->GetClass()->DescriptorEquals("Ljava/lang/Long;"))
<< "Expected java/lang/Long but found object of type "
<< orig_dex->GetClass()->PrettyClass();
art::ObjPtr<art::mirror::Class> prim_long_class(
art::GetClassRoot(art::ClassRoot::kPrimitiveLong));
art::JValue val; if (!art::UnboxPrimitiveForResult(orig_dex.Ptr(), prim_long_class, &val)) { // This should never happen.
LOG(FATAL) << "Unable to unbox a primitive long value!";
}
res = Init(*reinterpret_cast<const art::DexFile*>(static_cast<uintptr_t>(val.GetJ()))); if (res != OK) { return res;
}
} const art::DexFile& cur_dex = m_klass->GetDexFile();
current_dex_file_ =
art::ArrayRef<constunsignedchar>(cur_dex.Begin(), cur_dex.SizeIncludingSharedData()); return OK;
}
} // No redefinition must have ever happened so we can use the class's dex file. return Init(m_klass->GetDexFile());
}
jvmtiError ArtClassDefinition::Init(art::Thread* self, const jvmtiClassDefinition& def) {
jvmtiError res = InitCommon(self, def.klass); if (res != OK) { return res;
} // We are being directly redefined.
redefined_ = true;
current_dex_file_ = art::ArrayRef<constunsignedchar>(def.class_bytes, def.class_byte_count);
dex_data_ = art::ArrayRef<constunsignedchar>(def.class_bytes, def.class_byte_count); return OK;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.