From 4d4eff794fb8f911d149536f144e589279a51781 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Wed, 4 Mar 2015 22:46:35 -0800 Subject: ART: Fix compile-time-init fail It is possible that a class that isn't itself marked as an image class and would be skipped for compile-time-initialization by the compiler driver is initialized when initializing a second class that is an image class. If the second class only depended on the first class during initialization, e.g., to read field values, the compiler driver may discard the class object (not reachable from image classes), but record the oat class status as initialized (as it has been). In that case we miss the initialization when we load the class at runtime. Ensure that all initialized classes with a class initializer are considered image classes and retained. Bug: 19323020 Change-Id: I4e537f328d9a4ea23ed5ff7166d532b8855f7acd --- compiler/driver/compiler_driver.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 029fd46067..a52a83a28a 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -871,6 +871,11 @@ class ClinitImageUpdate { const char* name = klass->GetDescriptor(&temp); if (data->image_class_descriptors_->find(name) != data->image_class_descriptors_->end()) { data->image_classes_.push_back(klass); + } else { + // Check whether it is initialized and has a clinit. They must be kept, too. + if (klass->IsInitialized() && klass->FindClassInitializer() != nullptr) { + data->image_classes_.push_back(klass); + } } return true; -- cgit v1.2.3-59-g8ed1b