summaryrefslogtreecommitdiff
path: root/runtime/mirror/dex_cache-inl.h
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2025-02-07 19:05:44 +0000
committer Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-02-21 09:51:24 -0800
commita7d85a831f0a330ce9914c57ae146fc03193451c (patch)
tree0efa8d066859fa765c8f517358bdfc9da87356a5 /runtime/mirror/dex_cache-inl.h
parent191dd4948709c2bf6272f503e642d248740327cd (diff)
Support loading an ART file from a zip file.
Bug: 377474232 Test: art/test.py --host -g Change-Id: I1f8acd1d6eeff96cf83af8fcd5111865e114bcef
Diffstat (limited to 'runtime/mirror/dex_cache-inl.h')
-rw-r--r--runtime/mirror/dex_cache-inl.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h
index 4ac5131958..71ada5db9e 100644
--- a/runtime/mirror/dex_cache-inl.h
+++ b/runtime/mirror/dex_cache-inl.h
@@ -19,12 +19,14 @@
#include "dex_cache.h"
-#include <android-base/logging.h>
+#include <atomic>
+#include "android-base/logging.h"
#include "art_field.h"
#include "art_method.h"
#include "base/atomic_pair.h"
#include "base/casts.h"
+#include "base/globals.h"
#include "base/pointer_size.h"
#include "class_linker.h"
#include "dex/dex_file.h"
@@ -38,8 +40,6 @@
#include "runtime.h"
#include "write_barrier-inl.h"
-#include <atomic>
-
namespace art HIDDEN {
namespace mirror {
@@ -346,9 +346,17 @@ inline void DexCache::VisitNativeRoots(const Visitor& visitor) {
}
template <VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption>
-inline ObjPtr<String> DexCache::GetLocation() {
- return GetFieldObject<String, kVerifyFlags, kReadBarrierOption>(
+inline ObjPtr<String> DexCache::GetLocation(bool allow_location_mismatch) {
+ ObjPtr<String> location = GetFieldObject<String, kVerifyFlags, kReadBarrierOption>(
OFFSET_OF_OBJECT_MEMBER(DexCache, location_));
+ // At runtime, if the DexCache is from an app image or dynamically created, then its location must
+ // match the DexFile location.
+ // TODO(jiakaiz): Remove the AOT compiler and boot classpath checks?
+ if (kIsDebugBuild && !allow_location_mismatch && !Runtime::Current()->IsAotCompiler() &&
+ GetDexFile() != nullptr && !ClassLinker::IsBootClassLoader(GetClassLoader())) {
+ DCHECK_EQ(location->ToModifiedUtf8(), GetDexFile()->GetLocation());
+ }
+ return location;
}
} // namespace mirror