Add basic checks for redefinition.

This adds some checks for redefined classes. Currently it checks that
the transformed class has the same name, interfaces, and access flags.

Other checks will be added in the future.

Test: mma -j40 test-art-host
Change-Id: Iaa94e9e8688db1985d15f27acf3ddb53908a1c8b
diff --git a/runtime/openjdkjvmti/ti_redefine.h b/runtime/openjdkjvmti/ti_redefine.h
index 9d23ce4..d6bccb4 100644
--- a/runtime/openjdkjvmti/ti_redefine.h
+++ b/runtime/openjdkjvmti/ti_redefine.h
@@ -152,14 +152,29 @@
 
   void RecordFailure(jvmtiError result, const std::string& error_msg);
 
-  // TODO Actually write this.
   // 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 EnsureRedefinitionIsValid() {
-    LOG(WARNING) << "Redefinition is not checked for validity currently";
+  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.
+  bool CheckSameMethods() REQUIRES_SHARED(art::Locks::mutator_lock_) {
+    LOG(WARNING) << "methods are not checked for modification currently";
     return true;
   }
 
+  // Checks that the dex file does not modify fields
+  bool CheckSameFields() REQUIRES_SHARED(art::Locks::mutator_lock_) {
+    LOG(WARNING) << "Fields are not checked for modification currently";
+    return true;
+  }
+
+  // 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_);
+
   bool UpdateJavaDexFile(art::ObjPtr<art::mirror::Object> java_dex_file,
                          art::ObjPtr<art::mirror::LongArray> new_cookie,
                          /*out*/art::ObjPtr<art::mirror::LongArray>* original_cookie)