Only visit app image classes in class loader

Only update dex cache arrays of added classes since the declaring
class is in image DCHECK fails for other classes in the class loader.

Also some cleanup to prevent app images leaving invalid state if
they get rejected.

Bug: 22858531
Bug: 27431418
Change-Id: Ib2a5692a1ad78b014a1bfc6b27fb1c12bc8565e6
diff --git a/runtime/class_table.cc b/runtime/class_table.cc
index afb0556..d815b1a 100644
--- a/runtime/class_table.cc
+++ b/runtime/class_table.cc
@@ -168,8 +168,12 @@
 
 size_t ClassTable::ReadFromMemory(uint8_t* ptr) {
   size_t read_count = 0;
-  classes_.insert(classes_.begin(), ClassSet(ptr, /*make copy*/false, &read_count));
+  AddClassSet(ClassSet(ptr, /*make copy*/false, &read_count));
   return read_count;
 }
 
+void ClassTable::AddClassSet(ClassSet&& set) {
+  classes_.insert(classes_.begin(), std::move(set));
+}
+
 }  // namespace art