diff options
author | 2015-10-17 12:46:42 -0700 | |
---|---|---|
committer | 2015-10-19 12:30:45 -0700 | |
commit | 00310e0bb4ee541b99f0b687dbf5f706db2aabca (patch) | |
tree | bbb0bc2f829ed2ce145ca142c85da6181e2cd527 /runtime/class_table.cc | |
parent | 3ae313d9bc64eaa0c791452dd972654eae979496 (diff) |
Keep dex files live in class table
The DexFile.loadClass API allows callers to load classes using a
dex file without having that dex file owned by the specified class
loader. We now add the dex file to the class table to make sure it
stays live until the class loader is unreachable.
Fixes interpreter gcstress test 087 with 64 bit.
Bug: 22720414
Change-Id: Ia4341149f45b6293312f8b275c7a68cea179f718
Diffstat (limited to 'runtime/class_table.cc')
-rw-r--r-- | runtime/class_table.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/class_table.cc b/runtime/class_table.cc index 4b0cbc836c..3ed1c9540d 100644 --- a/runtime/class_table.cc +++ b/runtime/class_table.cc @@ -137,4 +137,15 @@ std::size_t ClassTable::ClassDescriptorHashEquals::operator()(const char* descri return ComputeModifiedUtf8Hash(descriptor); } +bool ClassTable::InsertDexFile(mirror::Object* dex_file) { + DCHECK(dex_file != nullptr); + for (GcRoot<mirror::Object>& root : dex_files_) { + if (root.Read() == dex_file) { + return false; + } + } + dex_files_.push_back(GcRoot<mirror::Object>(dex_file)); + return true; +} + } // namespace art |