ART: Add boot classpath check for initialization

Boot classpath classes should not fail initialization.

Test: m test-art-host
Change-Id: I48af3ab6ab3d5c2589b804df8f4585f5a81ea169
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 4905514..311d7d7 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -240,6 +240,12 @@
   ScopedLocalRef<jthrowable> cause(env, env->ExceptionOccurred());
   CHECK(cause.get() != nullptr);
 
+  // Boot classpath classes should not fail initialization.
+  if (!Runtime::Current()->IsAotCompiler()) {
+    std::string tmp;
+    CHECK(klass->GetClassLoader() != nullptr) << klass->GetDescriptor(&tmp);
+  }
+
   env->ExceptionClear();
   bool is_error = env->IsInstanceOf(cause.get(), WellKnownClasses::java_lang_Error);
   env->Throw(cause.get());