Refactor DexFile ownership

Avoid bare pointers in DexFileLoader APIs, which caused clang-tidy
issues and other problems.

Bug: none
Test: build and boot
Change-Id: Ic277bc83af1997774b42c55d3d631ec940b9c015
diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc
index e40f1db..2a2aff1 100644
--- a/runtime/class_linker_test.cc
+++ b/runtime/class_linker_test.cc
@@ -1521,12 +1521,12 @@
   dex_cache->SetLocation(location.Get());
   const DexFile* old_dex_file = dex_cache->GetDexFile();
 
-  std::unique_ptr<DexFile> dex_file(new StandardDexFile(old_dex_file->Begin(),
-                                                        old_dex_file->Size(),
-                                                        location->ToModifiedUtf8(),
-                                                        0u,
-                                                        nullptr,
-                                                        nullptr));
+  std::unique_ptr<DexFile> dex_file(
+      new StandardDexFile(std::make_unique<NonOwningDexFileContainer>(old_dex_file->Begin(),
+                                                                      old_dex_file->Size()),
+                          location->ToModifiedUtf8(),
+                          0u,
+                          nullptr));
   {
     WriterMutexLock mu(soa.Self(), *Locks::dex_lock_);
     // Check that inserting with a UTF16 name works.