ART: Move DexFile vector to Java array

To avoid having native vectors only referenced by Java objects,
which look like leaks to Valgrind, use a Java array to store
references to native DexFile objects.

Change-Id: If3c2b31b9d0914ed1965cfd5e3fdb94ea41b1477
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 3278751..3f37fa0 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2135,15 +2135,16 @@
           }
           mirror::Object* dex_file = dex_file_field->GetObject(element);
           if (dex_file != nullptr) {
-            const uint64_t cookie = cookie_field->GetLong(dex_file);
-            auto* dex_files =
-                reinterpret_cast<std::vector<const DexFile*>*>(static_cast<uintptr_t>(cookie));
-            if (dex_files == nullptr) {
+            mirror::LongArray* long_array = cookie_field->GetObject(dex_file)->AsLongArray();
+            if (long_array == nullptr) {
               // This should never happen so log a warning.
               LOG(WARNING) << "Null DexFile::mCookie for " << descriptor;
               break;
             }
-            for (const DexFile* cp_dex_file : *dex_files) {
+            int32_t long_array_size = long_array->GetLength();
+            for (int32_t j = 0; j < long_array_size; ++j) {
+              const DexFile* cp_dex_file = reinterpret_cast<const DexFile*>(static_cast<uintptr_t>(
+                  long_array->GetWithoutChecks(j)));
               const DexFile::ClassDef* dex_class_def = cp_dex_file->FindClassDef(descriptor, hash);
               if (dex_class_def != nullptr) {
                 RegisterDexFile(*cp_dex_file);