Merge "Add a check to ConcurrentCopying::MarkNonMoving for sticky-bit case."
diff --git a/runtime/gc/space/image_space.cc b/runtime/gc/space/image_space.cc
index 2a4803a..eebb103 100644
--- a/runtime/gc/space/image_space.cc
+++ b/runtime/gc/space/image_space.cc
@@ -1454,7 +1454,6 @@
         has_system_(false),
         has_cache_(false),
         is_global_cache_(true),
-        dalvik_cache_exists_(false),
         dalvik_cache_(),
         cache_filename_() {
   }
@@ -1463,30 +1462,33 @@
 
   void FindImageFiles() {
     std::string system_filename;
+    bool dalvik_cache_exists = false;
     bool found_image = FindImageFilenameImpl(image_location_.c_str(),
                                              image_isa_,
                                              &has_system_,
                                              &system_filename,
-                                             &dalvik_cache_exists_,
+                                             &dalvik_cache_exists,
                                              &dalvik_cache_,
                                              &is_global_cache_,
                                              &has_cache_,
                                              &cache_filename_);
-    DCHECK(!dalvik_cache_exists_ || !dalvik_cache_.empty());
+    DCHECK_EQ(dalvik_cache_exists, !dalvik_cache_.empty());
     DCHECK_EQ(found_image, has_system_ || has_cache_);
   }
 
   bool HasSystem() const { return has_system_; }
   bool HasCache() const { return has_cache_; }
 
-  bool DalvikCacheExists() const { return dalvik_cache_exists_; }
+  bool DalvikCacheExists() const { return !dalvik_cache_.empty(); }
   bool IsGlobalCache() const { return is_global_cache_; }
 
   const std::string& GetDalvikCache() const {
+    DCHECK(DalvikCacheExists());
     return dalvik_cache_;
   }
 
   const std::string& GetCacheFilename() const {
+    DCHECK(DalvikCacheExists());
     return cache_filename_;
   }
 
@@ -1615,7 +1617,6 @@
   bool has_system_;
   bool has_cache_;
   bool is_global_cache_;
-  bool dalvik_cache_exists_;
   std::string dalvik_cache_;
   std::string cache_filename_;
 };
@@ -1768,7 +1769,7 @@
 
   // Step 3: We do not have an existing image in /system,
   //         so generate an image into the dalvik cache.
-  if (!loader.HasSystem() && loader.DalvikCacheExists()) {
+  if (!loader.HasSystem()) {
     std::string local_error_msg;
     if (!dex2oat_enabled) {
       local_error_msg = "Image compilation disabled.";
diff --git a/runtime/gc/space/image_space_test.cc b/runtime/gc/space/image_space_test.cc
index b80a7bd..f202a43 100644
--- a/runtime/gc/space/image_space_test.cc
+++ b/runtime/gc/space/image_space_test.cc
@@ -150,37 +150,6 @@
   EXPECT_FALSE(Runtime::Current()->GetHeap()->GetBootImageSpaces().empty());
 }
 
-class NoAccessAndroidDataTest : public ImageSpaceLoadingTest<false, true, false, true> {
- protected:
-  void SetUpRuntimeOptions(RuntimeOptions* options) OVERRIDE {
-    const char* android_data = getenv("ANDROID_DATA");
-    CHECK(android_data != nullptr);
-    old_android_data_ = android_data;
-    bad_android_data_ = old_android_data_ + "/no-android-data";
-    int result = setenv("ANDROID_DATA", bad_android_data_.c_str(), /* replace */ 1);
-    CHECK_EQ(result, 0) << strerror(errno);
-    result = mkdir(bad_android_data_.c_str(), /* no access */ 0);
-    CHECK_EQ(result, 0) << strerror(errno);
-    ImageSpaceLoadingTest<false, true, false, true>::SetUpRuntimeOptions(options);
-  }
-
-  void TearDown() OVERRIDE {
-    int result = rmdir(bad_android_data_.c_str());
-    CHECK_EQ(result, 0) << strerror(errno);
-    result = setenv("ANDROID_DATA", old_android_data_.c_str(), /* replace */ 1);
-    CHECK_EQ(result, 0) << strerror(errno);
-    ImageSpaceLoadingTest<false, true, false, true>::TearDown();
-  }
-
- private:
-  std::string old_android_data_;
-  std::string bad_android_data_;
-};
-
-TEST_F(NoAccessAndroidDataTest, Test) {
-  EXPECT_TRUE(Runtime::Current()->GetHeap()->GetBootImageSpaces().empty());
-}
-
 }  // namespace space
 }  // namespace gc
 }  // namespace art