summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-10-02 21:05:45 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-10-02 21:05:45 +0000
commitb199063637192ec215ab6a2a86922cb41ce71e96 (patch)
treee532947f2f1b08ce00cd7cea4b8697b1d5dd3150
parent9f427c27768a188de561d1d26253123f0cd5a9fe (diff)
parent735c60fa21708f30905a2b7f5059ac0f3cf803b9 (diff)
downloadart-android13-qpr1-s2-release.tar.gz
Change-Id: I24f9eeb1d010f762c78bd13b647b90c19215ce29
-rw-r--r--runtime/class_linker.cc9
-rw-r--r--runtime/class_linker.h1
-rw-r--r--runtime/native/dalvik_system_DexFile.cc1
3 files changed, 11 insertions, 0 deletions
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index c8dbc75e61..f6f98e6192 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -10298,6 +10298,15 @@ void ClassLinker::SetEnablePublicSdkChecks(bool enabled ATTRIBUTE_UNUSED) {
UNREACHABLE();
}
+void ClassLinker::RemoveDexFromCaches(const DexFile& dex_file) {
+ ReaderMutexLock mu(Thread::Current(), *Locks::dex_lock_);
+
+ auto it = dex_caches_.find(&dex_file);
+ if (it != dex_caches_.end()) {
+ dex_caches_.erase(it);
+ }
+}
+
// Instantiate ClassLinker::AllocClass.
template ObjPtr<mirror::Class> ClassLinker::AllocClass</* kMovable= */ true>(
Thread* self,
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 3b20c75b64..a3a1adf839 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -837,6 +837,7 @@ class ClassLinker {
virtual bool DenyAccessBasedOnPublicSdk(const char* type_descriptor) const;
// Enable or disable public sdk checks.
virtual void SetEnablePublicSdkChecks(bool enabled);
+ void RemoveDexFromCaches(const DexFile& dex_file);
protected:
virtual bool InitializeClass(Thread* self,
diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc
index d714206241..ecb901044a 100644
--- a/runtime/native/dalvik_system_DexFile.cc
+++ b/runtime/native/dalvik_system_DexFile.cc
@@ -377,6 +377,7 @@ static jboolean DexFile_closeDexFile(JNIEnv* env, jclass, jobject cookie) {
if (!class_linker->IsDexFileRegistered(soa.Self(), *dex_file)) {
// Clear the element in the array so that we can call close again.
long_dex_files->Set(i, 0);
+ class_linker->RemoveDexFromCaches(*dex_file);
delete dex_file;
} else {
all_deleted = false;