From 29a533e30277e159327c24e27ed609d26479b2cd Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 23 Oct 2018 12:42:00 +0100 Subject: Remove unresolved classes from image classes. This allows compiling partial boot image, without conscrypt, while using the current image classes in preloaded-classes. Excluding the conscrypt makes the class android.security.net.config.TrustedCertificateStoreAdapter unresolved because it extends the class com.android.org.conscrypt.TrustedCertificateStore . Without pruning, we hit a DCHECK() in ImageWriter, checking that image classes are not erroneous. And we clearly do not want to put erroneous classes in the partial boot image. Test: Build partial boot image without conscrypt. Bug: 119868597 Change-Id: I6017462366a4b9e69abe1fb3d22461cab35f84c5 --- compiler/driver/compiler_driver.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 0039be0fde..f52c566727 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -1231,8 +1231,15 @@ class ClinitImageUpdate { bool operator()(ObjPtr klass) override REQUIRES_SHARED(Locks::mutator_lock_) { std::string temp; StringPiece name(klass->GetDescriptor(&temp)); - if (data_->image_class_descriptors_->find(name) != data_->image_class_descriptors_->end()) { - data_->image_classes_.push_back(hs_.NewHandle(klass)); + auto it = data_->image_class_descriptors_->find(name); + if (it != data_->image_class_descriptors_->end()) { + if (LIKELY(klass->IsResolved())) { + data_->image_classes_.push_back(hs_.NewHandle(klass)); + } else { + DCHECK(klass->IsErroneousUnresolved()); + VLOG(compiler) << "Removing unresolved class from image classes: " << name; + data_->image_class_descriptors_->erase(it); + } } else { // Check whether it is initialized and has a clinit. They must be kept, too. if (klass->IsInitialized() && klass->FindClassInitializer( -- cgit v1.2.3-59-g8ed1b