Remove dex2oat image-classes support

Deprecated, new approach is to use boot image profile.

Test: test-art-host
Bug: 63746626

Change-Id: I5332b6f00ce91faab3df3e9e66e17abd0f8ee059
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index c576f2c..c1504cc 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -273,9 +273,6 @@
   UsageError("      Example: --image-format=lz4");
   UsageError("      Default: uncompressed");
   UsageError("");
-  UsageError("  --image-classes=<classname-file>: specifies classes to include in an image.");
-  UsageError("      Example: --image=frameworks/base/preloaded-classes");
-  UsageError("");
   UsageError("  --base=<hex-address>: specifies the base address when creating a boot image.");
   UsageError("      Example: --base=0x50000000");
   UsageError("");
@@ -672,8 +669,6 @@
       dm_fd_(-1),
       zip_fd_(-1),
       image_base_(0U),
-      image_classes_zip_filename_(nullptr),
-      image_classes_filename_(nullptr),
       image_storage_mode_(ImageHeader::kStorageModeUncompressed),
       passes_to_run_filename_(nullptr),
       dirty_image_objects_filename_(nullptr),
@@ -848,18 +843,6 @@
       boot_image_filename_ = parser_options->boot_image_filename;
     }
 
-    if (image_classes_filename_ != nullptr && !IsBootImage()) {
-      Usage("--image-classes should only be used with --image");
-    }
-
-    if (image_classes_filename_ != nullptr && !boot_image_filename_.empty()) {
-      Usage("--image-classes should not be used with --boot-image");
-    }
-
-    if (image_classes_zip_filename_ != nullptr && image_classes_filename_ == nullptr) {
-      Usage("--image-classes-zip should be used with --image-classes");
-    }
-
     if (dex_filenames_.empty() && zip_fd_ == -1) {
       Usage("Input must be supplied with either --dex-file or --zip-fd");
     }
@@ -900,13 +883,6 @@
       Usage("Profile file should not be specified with both --profile-file-fd and --profile-file");
     }
 
-    if (have_profile_file || have_profile_fd) {
-      if (image_classes_filename_ != nullptr ||
-          image_classes_zip_filename_ != nullptr) {
-        Usage("Profile based image creation is not supported with image or compiled classes");
-      }
-    }
-
     if (!parser_options->oat_symbols.empty()) {
       oat_unstripped_ = std::move(parser_options->oat_symbols);
     }
@@ -1138,8 +1114,6 @@
     AssignIfExists(args, M::Watchdog, &parser_options->watch_dog_enabled);
     AssignIfExists(args, M::WatchdogTimeout, &parser_options->watch_dog_timeout_in_ms);
     AssignIfExists(args, M::Threads, &thread_count_);
-    AssignIfExists(args, M::ImageClasses, &image_classes_filename_);
-    AssignIfExists(args, M::ImageClassesZip, &image_classes_zip_filename_);
     AssignIfExists(args, M::Passes, &passes_to_run_filename_);
     AssignIfExists(args, M::BootImage, &parser_options->boot_image_filename);
     AssignIfExists(args, M::AndroidRoot, &android_root_);
@@ -1466,8 +1440,6 @@
           LOG(INFO) << "Image class " << s;
         }
       }
-      // Note: If we have a profile, classes previously loaded for the --image-classes
-      // option are overwritten here.
       compiler_options_->image_classes_.swap(image_classes);
     }
   }
@@ -1477,7 +1449,7 @@
   dex2oat::ReturnCode Setup() {
     TimingLogger::ScopedTiming t("dex2oat Setup", timings_);
 
-    if (!PrepareImageClasses() || !PrepareDirtyObjects()) {
+    if (!PrepareDirtyObjects()) {
       return dex2oat::ReturnCode::kOther;
     }
 
@@ -2329,37 +2301,6 @@
     return dex_files_size >= very_large_threshold_;
   }
 
-  bool PrepareImageClasses() {
-    // If --image-classes was specified, calculate the full list of classes to include in the image.
-    DCHECK(compiler_options_->image_classes_.empty());
-    if (image_classes_filename_ != nullptr) {
-      std::unique_ptr<HashSet<std::string>> image_classes =
-          ReadClasses(image_classes_zip_filename_, image_classes_filename_, "image");
-      if (image_classes == nullptr) {
-        return false;
-      }
-      compiler_options_->image_classes_.swap(*image_classes);
-    }
-    return true;
-  }
-
-  static std::unique_ptr<HashSet<std::string>> ReadClasses(const char* zip_filename,
-                                                           const char* classes_filename,
-                                                           const char* tag) {
-    std::unique_ptr<HashSet<std::string>> classes;
-    std::string error_msg;
-    if (zip_filename != nullptr) {
-      classes = ReadImageClassesFromZip(zip_filename, classes_filename, &error_msg);
-    } else {
-      classes = ReadImageClassesFromFile(classes_filename);
-    }
-    if (classes == nullptr) {
-      LOG(ERROR) << "Failed to create list of " << tag << " classes from '"
-                 << classes_filename << "': " << error_msg;
-    }
-    return classes;
-  }
-
   bool PrepareDirtyObjects() {
     if (dirty_image_objects_filename_ != nullptr) {
       dirty_image_objects_ = ReadCommentedInputFromFile<HashSet<std::string>>(
@@ -2607,25 +2548,6 @@
     return true;
   }
 
-  // Reads the class names (java.lang.Object) and returns a set of descriptors (Ljava/lang/Object;)
-  static std::unique_ptr<HashSet<std::string>> ReadImageClassesFromFile(
-      const char* image_classes_filename) {
-    std::function<std::string(const char*)> process = DotToDescriptor;
-    return ReadCommentedInputFromFile<HashSet<std::string>>(image_classes_filename, &process);
-  }
-
-  // Reads the class names (java.lang.Object) and returns a set of descriptors (Ljava/lang/Object;)
-  static std::unique_ptr<HashSet<std::string>> ReadImageClassesFromZip(
-        const char* zip_filename,
-        const char* image_classes_filename,
-        std::string* error_msg) {
-    std::function<std::string(const char*)> process = DotToDescriptor;
-    return ReadCommentedInputFromZip<HashSet<std::string>>(zip_filename,
-                                                           image_classes_filename,
-                                                           &process,
-                                                           error_msg);
-  }
-
   // Read lines from the given file, dropping comments and empty lines. Post-process each line with
   // the given function.
   template <typename T>
@@ -2773,8 +2695,6 @@
   std::vector<const char*> runtime_args_;
   std::vector<std::string> image_filenames_;
   uintptr_t image_base_;
-  const char* image_classes_zip_filename_;
-  const char* image_classes_filename_;
   ImageHeader::StorageMode image_storage_mode_;
   const char* passes_to_run_filename_;
   const char* dirty_image_objects_filename_;