ART: Change Init{From,Without}Image to return bool
Rewrite some CHECKs to return false. For a common failure (missing)
image, this improves the abort (as it's not a runtime abort with
lots of stack traces anymore).
Change-Id: I717b1db74950267ced0ad3bafa1aed1693680062
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 92a56a9..db30a90 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -1041,8 +1041,13 @@
class_linker_ = new ClassLinker(intern_table_);
if (GetHeap()->HasImageSpace()) {
ATRACE_BEGIN("InitFromImage");
- class_linker_->InitFromImage();
+ std::string error_msg;
+ bool result = class_linker_->InitFromImage(&error_msg);
ATRACE_END();
+ if (!result) {
+ LOG(ERROR) << "Could not initialize from image: " << error_msg;
+ return false;
+ }
if (kIsDebugBuild) {
GetHeap()->GetBootImageSpace()->VerifyImageAllocations();
}
@@ -1074,7 +1079,11 @@
runtime_options.GetOrDefault(Opt::Image),
&boot_class_path);
instruction_set_ = runtime_options.GetOrDefault(Opt::ImageInstructionSet);
- class_linker_->InitWithoutImage(std::move(boot_class_path));
+ std::string error_msg;
+ if (!class_linker_->InitWithoutImage(std::move(boot_class_path), &error_msg)) {
+ LOG(ERROR) << "Could not initialize without image: " << error_msg;
+ return false;
+ }
// TODO: Should we move the following to InitWithoutImage?
SetInstructionSet(instruction_set_);