Check stacks for unmodifiable frames

We keep a generate a list of classes that have unmodifiable frames
during the zygote fork and check for them in IsModifiableClass.

Test: Start apps on aosp_marlin-userdebug phone with libartd.so

Change-Id: I6bbaa20d307c3803a5808fb4108638365895e802
diff --git a/runtime/openjdkjvmti/ti_redefine.cc b/runtime/openjdkjvmti/ti_redefine.cc
index 2d532d1..c0dc16a 100644
--- a/runtime/openjdkjvmti/ti_redefine.cc
+++ b/runtime/openjdkjvmti/ti_redefine.cc
@@ -56,6 +56,7 @@
 #include "mirror/class-inl.h"
 #include "mirror/class_ext.h"
 #include "mirror/object.h"
+#include "non_debuggable_classes.h"
 #include "object_lock.h"
 #include "runtime.h"
 #include "ScopedLocalRef.h"
@@ -245,8 +246,13 @@
     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";
+  for (jclass c : art::NonDebuggableClasses::GetNonDebuggableClasses()) {
+    if (klass.Get() == art::Thread::Current()->DecodeJObject(c)->AsClass()) {
+      *error_msg = "Class might have stack frames that cannot be made obsolete";
+      return ERR(UNMODIFIABLE_CLASS);
+    }
+  }
+
   return OK;
 }