Fix determinism for app images
Clear the dalvik.system.DexFile cookie to make the long array
unreachable before the GC.
Test: test-art-host
Test: Ran 10x: mma -j40 && shasum $OUT/system/framework/oat/arm64/services.* && rm $OUT/system/framework/oat/arm64/services.* && rm $OUT/obj/JAVA_LIBRARIES/services_intermediates/oat/arm64/*
Bug: 34090128
Change-Id: I5a872de3e907461803a77254902d78ff6e657b43
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 3ecf595..694c113 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -8705,6 +8705,8 @@
DCHECK(h_long_array != nullptr);
h_long_array->Set(kDexFileIndexStart, reinterpret_cast<intptr_t>(dex_file));
+ // Note that this creates a finalizable dalvik.system.DexFile object and a corresponding
+ // FinalizerReference which will never get cleaned up without a started runtime.
Handle<mirror::Object> h_dex_file = hs2.NewHandle(
cookie_field->GetDeclaringClass()->AllocObject(self));
DCHECK(h_dex_file != nullptr);