Revert "Add basic implementation of IsModifiableClass"
Built on top of a failing change.
This reverts commit b4e51ebfa23a1cb175a6c317ac4a69228709e78f.
Change-Id: I7f4dbe22271a9c04e518bceabba12c95cad3c6f7
diff --git a/runtime/openjdkjvmti/ti_redefine.cc b/runtime/openjdkjvmti/ti_redefine.cc
index adec6c9..6b0e9c8 100644
--- a/runtime/openjdkjvmti/ti_redefine.cc
+++ b/runtime/openjdkjvmti/ti_redefine.cc
@@ -195,45 +195,6 @@
std::string* error_msg_;
};
-jvmtiError Redefiner::IsModifiableClass(jvmtiEnv* env ATTRIBUTE_UNUSED,
- jclass klass,
- jboolean* is_redefinable) {
- // TODO Check for the appropriate feature flags once we have enabled them.
- art::Thread* self = art::Thread::Current();
- art::ScopedObjectAccess soa(self);
- art::StackHandleScope<1> hs(self);
- art::ObjPtr<art::mirror::Object> obj(self->DecodeJObject(klass));
- if (obj.IsNull()) {
- return ERR(INVALID_CLASS);
- }
- art::Handle<art::mirror::Class> h_klass(hs.NewHandle(obj->AsClass()));
- std::string err_unused;
- *is_redefinable =
- Redefiner::GetClassRedefinitionError(h_klass, &err_unused) == OK ? JNI_TRUE : JNI_FALSE;
- return OK;
-}
-
-jvmtiError Redefiner::GetClassRedefinitionError(art::Handle<art::mirror::Class> klass,
- /*out*/std::string* error_msg) {
- if (klass->IsPrimitive()) {
- *error_msg = "Modification of primitive classes is not supported";
- return ERR(UNMODIFIABLE_CLASS);
- } else if (klass->IsInterface()) {
- *error_msg = "Modification of Interface classes is currently not supported";
- return ERR(UNMODIFIABLE_CLASS);
- } else if (klass->IsArrayClass()) {
- *error_msg = "Modification of Array classes is not supported";
- return ERR(UNMODIFIABLE_CLASS);
- } else if (klass->IsProxyClass()) {
- *error_msg = "Modification of proxy classes is not supported";
- return ERR(UNMODIFIABLE_CLASS);
- }
-
- // TODO We should check if the class has non-obsoletable methods on the stack
- LOG(WARNING) << "presence of non-obsoletable methods on stacks is not currently checked";
- return OK;
-}
-
// Moves dex data to an anonymous, read-only mmap'd region.
std::unique_ptr<art::MemMap> Redefiner::MoveDataToMemMap(const std::string& original_location,
jint data_len,
@@ -664,17 +625,28 @@
// TODO Move this to use IsRedefinable when that function is made.
bool Redefiner::CheckRedefinable() {
- std::string err;
- art::StackHandleScope<1> hs(self_);
-
- art::Handle<art::mirror::Class> h_klass(hs.NewHandle(GetMirrorClass()));
- jvmtiError res = Redefiner::GetClassRedefinitionError(h_klass, &err);
- if (res != OK) {
- RecordFailure(res, err);
+ art::ObjPtr<art::mirror::Class> klass(GetMirrorClass());
+ if (klass->IsPrimitive()) {
+ RecordFailure(ERR(UNMODIFIABLE_CLASS),
+ "Modification of primitive classes is not supported");
return false;
- } else {
- return true;
+ } else if (klass->IsInterface()) {
+ RecordFailure(ERR(UNMODIFIABLE_CLASS),
+ "Modification of Interface classes is currently not supported");
+ return false;
+ } else if (klass->IsArrayClass()) {
+ RecordFailure(ERR(UNMODIFIABLE_CLASS),
+ "Modification of Array classes is not supported");
+ return false;
+ } else if (klass->IsProxyClass()) {
+ RecordFailure(ERR(UNMODIFIABLE_CLASS),
+ "Modification of proxy classes is not supported");
+ return false;
}
+
+ // TODO We should check if the class has non-obsoletable methods on the stack
+ LOG(WARNING) << "presence of non-obsoletable methods on stacks is not currently checked";
+ return true;
}
bool Redefiner::CheckRedefinitionIsValid() {