// Class that can redefine a single class's methods. class Redefiner { public: // Redefine the given classes with the given dex data. Note this function does not take ownership // of the dex_data pointers. It is not used after this call however and may be freed if desired. // The caller is responsible for freeing it. The runtime makes its own copy of the data. This // function does not call the transformation events. static jvmtiError RedefineClassesDirect(ArtJvmTiEnv* env,
art::Runtime* runtime,
art::Thread* self, const std::vector<ArtClassDefinition>& definitions,
RedefinitionType type, /*out*/std::string* error_msg);
// Redefine the given classes with the given dex data. Note this function does not take ownership // of the dex_data pointers. It is not used after this call however and may be freed if desired. // The caller is responsible for freeing it. The runtime makes its own copy of the data. static jvmtiError RedefineClasses(jvmtiEnv* env,
jint class_count, const jvmtiClassDefinition* definitions); static jvmtiError StructurallyRedefineClasses(jvmtiEnv* env,
jint class_count, const jvmtiClassDefinition* definitions);
// NO_THREAD_SAFETY_ANALYSIS so we can unlock the class in the destructor.
~ClassRedefinition() NO_THREAD_SAFETY_ANALYSIS;
// Move assignment so we can sort these in a vector.
ClassRedefinition& operator=(ClassRedefinition&& other) noexcept {
driver_ = other.driver_;
klass_ = other.klass_;
dex_file_ = std::move(other.dex_file_);
class_sig_ = std::move(other.class_sig_);
original_dex_file_ = other.original_dex_file_;
other.driver_ = nullptr; return *this;
}
// Move constructor so we can put these into a vector.
ClassRedefinition(ClassRedefinition&& other) noexcept
: driver_(other.driver_),
klass_(other.klass_),
dex_file_(std::move(other.dex_file_)),
class_sig_(std::move(other.class_sig_)),
original_dex_file_(other.original_dex_file_) {
other.driver_ = nullptr;
}
// No copy!
ClassRedefinition(ClassRedefinition&) = delete;
ClassRedefinition& operator=(ClassRedefinition&) = delete;
// This may return nullptr with a OOME pending if allocation fails.
art::mirror::Object* AllocateOrGetOriginalDexFile()
REQUIRES_SHARED(art::Locks::mutator_lock_);
// Checks that the dex file contains only the single expected class and that the top-level class // data has not been modified in an incompatible manner. bool CheckClass() REQUIRES_SHARED(art::Locks::mutator_lock_);
// Checks that the contained class can be successfully verified. bool CheckVerification(const RedefinitionDataIter& holder)
REQUIRES_SHARED(art::Locks::mutator_lock_);
// Preallocates all needed allocations in klass so that we can pause execution safely. bool EnsureClassAllocationsFinished(/*out*/RedefinitionDataIter* data)
REQUIRES_SHARED(art::Locks::mutator_lock_);
// This will check that no constraints are violated (more than 1 class in dex file, any changes // in number/declaration of methods & fields, changes in access flags, etc.) bool CheckRedefinitionIsValid() REQUIRES_SHARED(art::Locks::mutator_lock_);
// Checks that the class can even be redefined. bool CheckRedefinable() REQUIRES_SHARED(art::Locks::mutator_lock_);
// Checks that the dex file does not add/remove methods, or change their modifiers or types in // illegal ways. bool CheckMethods() REQUIRES_SHARED(art::Locks::mutator_lock_);
// Checks that the dex file does not modify fields types or modifiers in illegal ways. bool CheckFields() REQUIRES_SHARED(art::Locks::mutator_lock_);
// Temporary check that a class undergoing structural redefinition has no instances. This // requirement will be removed in time. void UpdateJavaDexFile(art::ObjPtr<art::mirror::Object> java_dex_file,
art::ObjPtr<art::mirror::LongArray> new_cookie)
REQUIRES(art::Locks::mutator_lock_);
ArtJvmTiEnv* env_;
jvmtiError result_;
art::Runtime* runtime_;
art::Thread* self_;
RedefinitionType type_;
std::vector<ClassRedefinition> redefinitions_; // Kept as a jclass since we have weird run-state changes that make keeping it around as a // mirror::Class difficult and confusing.
std::string* error_msg_;
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.