Don't fail oat writing for unresolvable classes.

Change-Id: I48f3aa15bed80fbda6285525c0c888b3c07c2b52
diff --git a/src/oat_writer.cc b/src/oat_writer.cc
index 2635bf8..26ce7c1 100644
--- a/src/oat_writer.cc
+++ b/src/oat_writer.cc
@@ -142,7 +142,13 @@
   // TODO: remove code ByteArrays from Class/Method (and therefore ClassLoader)
   // TODO: don't write code for shared stubs
   Class* klass = Runtime::Current()->GetClassLinker()->FindClass(descriptor, class_loader_);
-  CHECK(klass != NULL) << descriptor;
+  if (klass == NULL) {
+    LOG(WARNING) << "Didn't find class '" << descriptor << "' in dex file " << dex_file.GetLocation();
+    Thread* thread = Thread::Current();
+    DCHECK(thread->IsExceptionPending());
+    thread->ClearException();
+    return offset;
+  }
   CHECK_EQ(klass->GetClassLoader(), class_loader_);
   CHECK_EQ(oat_methods_[oat_class_index]->method_offsets_.size(),
            klass->NumDirectMethods() + num_virtual_methods);
@@ -357,6 +363,13 @@
   const char* descriptor = dex_file.GetClassDescriptor(class_def);
   ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
   Class* klass = class_linker->FindClass(descriptor, class_loader_);
+  if (klass == NULL) {
+    LOG(WARNING) << "Didn't find class '" << descriptor << "' in dex file " << dex_file.GetLocation();
+    Thread* thread = Thread::Current();
+    DCHECK(thread->IsExceptionPending());
+    thread->ClearException();
+    return code_offset;
+  }
 
   // TODO: deduplicate code arrays
   // Note that we clear the code array here, image_writer will use GetCodeOffset to find it