summaryrefslogtreecommitdiff
path: root/runtime/class_loader_context_test.cc
AgeCommit message (Collapse)Author
2024-06-13Use C++20 `string{,_view}::{starts,ends}_with()`, part 1. Vladimir Marko
Remove the header file `string_view_cpp20.h` and update all source files that previously used this header file. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Iafcdfc838a97deed7fb3a37cc8afe1f7ee78306b
2024-01-24Add visibility attributes in runtime/c* Dmitrii Ishcheikin
Bug: 260881207 Test: presubmit Test: abtd app_compat_drm Test: abtd app_compat_top_100 Test: abtd app_compat_banking Change-Id: Id729aca1d8b6d003ff3e9755112f3283e9f2b507
2024-01-19Move files related to compiled code into oat/ directory Dmitrii Ishcheikin
Test: art/test.py -b --host Change-Id: Icedd3a82c6bca5147c3bc9dc50de5a729003d66f
2023-11-17Fix the ClassLoaderContext mismatch error message. Jiakai Zhang
Before this change, ClassLoaderContext encoding relied on `info.opened_dex_files`. This doesn't work for the error message presentation because we no longer open dex files for ClassLoaderContext verification since https://r.android.com/1531339. This problem leads to empty dex paths in the error message and causes confusion. Note that it does not affect the correctness of ClassLoaderContext verification. This change fixes the presentation problem. Bug: 311126962 Test: m test-art-host-gtest-art_runtime_tests Change-Id: I83972aba7d06a086b7684e2c7ac7640e135e0ee0
2023-08-03Allow location duplicates when encoding class loader context David Srbecky
Bug: 293664704 Test: Run the app from the above bug Test: m test-art-host-gtest-art_runtime_tests64 Change-Id: Ib2e3f0987c6cbc5f3cad1639a2259fc9882e0477
2023-07-04Revert^2 "Reduce multidex checksum to single scalar value." David Srbecky
Change GetMultiDexChecksums to return a single value rather than a vector. The single checksum represents the whole multidex set, and will change if any dex file within the multidex set changes. Fundamentally, we need a value to represent a .zip/.jar archive, so that we can check whether our build artifacts are up to date. We previously used a vector of CRC32 values (one per dex file), however, one combined checksum per archive is also sufficient. This is necessary, since the future multidex format will have single zip entry, so we need to adjust the code to expect just one checksum per zip file. This separates the change to own CL. The two sides of the checksum comparison are trivially reduced: * Zip files are reduced by XORing the individual CRC values. * Likewise, checksums of already open DexFiles are XORed. As a consequence, ClassLoader path needs to be reduced to print only single checksum per jar file as well. Bug: 266950186 Test: ./art/test.py -b --host Change-Id: I2782d7204e913d9f8e12ce80438ed98af5d42991
2023-07-03Revert "Reduce multidex checksum to single scalar value." David Srbecky
This reverts commit fdfa590b7b43ca70e497f1a8afe9a641b57ece56. Reason for revert: b/289784075 Change-Id: Ib114ca32dac6d1aaced372334873bfa12f74d572
2023-07-03Reduce multidex checksum to single scalar value. David Srbecky
Change GetMultiDexChecksums to return a single value rather than a vector. The single checksum represents the whole multidex set, and will change if any dex file within the multidex set changes. Fundamentally, we need a value to represent a .zip/.jar archive, so that we can check whether our build artifacts are up to date. We previously used a vector of CRC32 values (one per dex file), however, one combined checksum per archive is also sufficient. This is necessary, since the future multidex format will have single zip entry, so we need to adjust the code to expect just one checksum per zip file. This separates the change to own CL. The two sides of the checksum comparison are trivially reduced: * Zip files are reduced by XORing the individual CRC values. * Likewise, checksums of already open DexFiles are XORed. As a consequence, ClassLoader path needs to be reduced to print only single checksum per jar file as well. Bug: 266950186 Test: ./art/test.py -b --host Change-Id: I848aee1e4836e87945a5172c7594e266739451e9
2022-12-02Remove class root duplicates from well known classes. Vladimir Marko
And get well known exception classes as declaring classes of their constructors. Also change function `ThreadForEnv()` to `Thread::ForEnv()` and use it where appropriate, mostly in code added recently while cleaning up well-known methods. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I2ededa429863a6cddbcbb879a223277fd6245557
2022-11-29Change well known class loader methods to `ArtMethod*`. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: atest CtsJdwpTestCases Change-Id: I7b94a481304f8899bcb828ed5875fe165dd90dda
2022-11-09Clean up decoding well-known classes. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I27b4e8f5513511ce1c320e3224dd9c2a40880b69
2022-10-18Reland "Change well known `ClassLoader` fields to `ArtField*`." Vladimír Marko
This reverts commit 839193ee2031d28aac2ce16c4b76ad40531b07cc. Reason for revert: Reland with a fix - make CompilerDriver reponsible for initializing required `ClassLoader` classes for boot image. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: Manually run Golem benchmark ArrayListStress. Bug: 253570082 Change-Id: I2ddb70566352f8728f089b3a6c58473270240e25
2022-10-17Revert "Change well known `ClassLoader` fields to `ArtField*`." Vladimír Marko
This reverts commit afe6902accb6a4d3b3382cc501c4d005b6fb5b96. Reason for revert: This may have broken Golem benchmarks. Bug: 253570082 Change-Id: I5507a4591c0bad8d778820f6fafc61fdc65e2f54
2022-10-17Change well known `ClassLoader` fields to `ArtField*`. Vladimir Marko
Note that the new field caching does not resolve the field's type and does not initialize the class holding the field. There is no reason why the `WellKnownClasses` should be responsible for this type resolution and initialization. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 253570082 Change-Id: I692afdc891d161c813864543e47a2c02f93e93e8
2022-10-14ART: Speed up some gtests. Vladimir Marko
Avoid creating `Runtime` or create the `Runtime` with a boot image to make the test setup faster. Test: m test-art-host-gtest Test: run-gtests.sh Change-Id: I3f09de81491402442f1704d25bb06de995d8a3ca
2022-09-30Resolve symlinks when checking class loader context. Jiakai Zhang
There is some inconsistency in the build system. When /system_ext is a symlink to /system/system_ext and there is a shared library in /system_ext, the oat file generated by dexpreopt has the dex location starting with /system/system_ext, while the metadata in /system_ext/etc/permissions has the dex location starting with /system_ext. This inconsitency causes the class loader context to fail. This CL works around the inconsistency by resolving symlinks when checking class loader context. Bug: 247914536 Test: m test-art-host-gtest-art_runtime_tests Change-Id: I7a177bda08e179c3d5417108be6411a84fdd5c40
2021-10-26Add support to place shared libraries after the dex path Brad Stenning
This allows for a shared library to overriden by content in the dex path Bug: 179429740 Test: m test-art-host-gtest-art_runtime_tests32 Change-Id: I5f69c7bf32b7bd389eff8bdbb21616ba89ed9e87
2021-03-29Remove '&' class loader context. Nicolas Geoffray
This is now an unsupported context. Test: class_loader_context Bug: 132357300 Change-Id: I21bc6e3529944a57379845e90c7f49759db30d40
2021-01-05Do not open dex files in CLC if we only need to get dexopt status Calin Juravle
The verifying the class loader context when calling GetDexOptNeeded we only need the dex locations and the checksums. Opening the full dex files may lead to in memory extraction which is expensive and unnecessary. Add a special path in ClassLoaderContext::OpenDexFiles which will extract the locations and the checksums from the apk instead of actually opening the dex files. We re-uses the same logic in OpenDexFiles in order to avoid implementing the opening algorithm twice (which, given all the edge cases is not trivial). Bug: 169869944 Test: test-art-host Change-Id: Ic327889677ce697cd60c5c688281515b932a2a76
2020-12-14Remove stripped-apk related logic from CLC Calin Juravle
Stripped-apks are no longer supported by the runtime and the current logic prevents bug fixes and code evolution. Bug: 111442216 Test: test-art-host Change-Id: I30d5825e4f6453981ca9165bebafe67557c28b93
2020-06-25Search only the current class loader when checking for duplicates Calin Juravle
Do not check the entire class loader hierarchy for duplicate dex files because some use cases might be valid. The most error prone cases are actually duplicates within the same class loader. Test: gtest Bug: 154032843 Change-Id: I8c5efd4b2053a5b4052de6041d561554dddf4780 Merged-In: I8c5efd4b2053a5b4052de6041d561554dddf4780 (cherry picked from commit 86ac525b1f42876518c9040aeaf1a9710cc4332e)
2020-05-13Move implementations from class_root.h to -inl.h . Vladimir Marko
Make it possible to include the definition of enum ClassRoot without pulling in a lot of other headers. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: aosp_taimen-userdebug boots. Change-Id: Ic90fdd70bfe0c5428a5c9a0d7901ea7e15b03488
2020-04-08Log an error when an app loads duplicate dex files Calin Juravle
Creating a class loader with duplicate dex files in its classpath is most likely an unintended bug. That leads to rejecting any compiled code and hurts performance by extracting in memory. Test: run-test gtest Bug: 149410951 Change-Id: Ieebb69c6bd03acbe95dd8bedb6101d70390b92d8
2020-02-08Introduce VMRuntime.isValidClassLoaderContext Dan Zimmerman
In the PackageManager server we need to validate class loader contexts that we receive from an untrusted process. In order to keep class loader context parsing logic centralized within the runtime let's create an API which returns whether or not the runtime can parse the encoded class loader context. Test: Build system image, open app using secondary dex Test: atest atest com.android.server.pm.dex.DexManagerTests Test: m test-art-host-gtest-class_loader_context_test Change-Id: Ied676e3239f70a8ab9d066df79f377b7036b28b7
2020-02-08Introduce BaseDexClassLoader.computeClassLoaderContextsNative Dan Zimmerman
This will be used to compute the contexts that should be sent over to the dex load reporter. See associated changes in libcore & frameworks/base. Motivation: At the moment of committing there are two classloader context encoders- one in ART and one in the package manager. The duplicate logic is susceptible to divergences. For example at the moment if a package uses shared libraries and has secondary dex files then the context encoded for secondary dex files will be incorrect[1]. In order to eliminate this bug and future possible bugs lets centralize where all classloader context computation is done. [1]: The context will be incorrect because it doesn't take into account the shared libraries that are loaded at runtime. Test: m test-art-host-gtest-class_loader_context_test Test: m test-art-host-gtest Test: ./test/testrunner/testrunner.py --host -b Test: Introduced a set of tests for the new API(s) Test: See tests in associated libcore & framework/base commits Bug: 148494302 Change-Id: Id39293a2e1d3d05194f2864f4febb3e652bce075
2019-11-28Simplify name verification in ClassLoaderContext. Vladimir Marko
Do not go through OatFile::ResolveRelativeEncodedDexLocation to avoid unnecessary handling of multi-dex suffix. That was broken anyway because `abs_dex_location` is not expected to be a multi-dex location as demonstrated by an additional test which would have previously failed. Test: Improved test in class_loader_context_test. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: I0a292ed1442393a3de4e8a360593b607b1b37cfd
2019-04-01Revert^2: InMemoryDexClassLoader in ClassLoaderContext follow-up David Brazdil
Address follow-up comments on Ic64065819018a1e56dee0f65405d26beb8fd7bbd. In particular, the classpath elements of IMC are replaced with "<unknown>" magic value to make it clear that the dex location is bogus, and a clarifying comment is added. Previously this CL would fail on target because IMC classpath was not being replaced with "<unknown>" and context matching failed. This was only a problem on target because OatFile::ResolveRelativeEncodedDexLocation ignores non-absolute locations on host. This reverts commit 93d99f3665cbd890509f4c707e1a62c5f26d320e. Test: m test-art-gtest-class_loader_context_test Bug: 72131483 Change-Id: I27cbfa69c24d412cc1b6bcce88218cc95e324ef5
2019-04-01ObjPtr<>-ify StackTraceElement and ClassLoader. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: I457eeda55bbfb905dd2de0abd68451ab42ef9c1f
2019-03-27ObjPtr<>-ify mirror::ObjectArray. Vladimir Marko
Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 31113334 Change-Id: I611b3e49d3feed306f6cd35d2b662a1e727e24c6
2019-03-27Revert "InMemoryDexClassLoader in ClassLoaderContext follow-up" Nicolas Geoffray
This reverts commit 1a1398ec15accbd905d802e1391c8efbd2d80f98. Bug: 72131483 Reason for revert: Broke class_loader_context_test on target Change-Id: Iaa51c8e84536638f39e9ca4c420d1e10ae15e270
2019-03-26InMemoryDexClassLoader in ClassLoaderContext follow-up David Brazdil
Address follow-up comments on Ic64065819018a1e56dee0f65405d26beb8fd7bbd. In particular, the classpath elements of IMC are replaced with "<unknown>" magic value to make it clear that the dex location is bogus, and a clarifying comment is added. Test: m test-art-gtest-class_loader_context_test Bug: 72131483 Change-Id: I0225c288a07af589a3f3d85a69ef908eeab38cb2
2019-03-22Support InMemoryDexClassLoader in ClassLoaderContext David Brazdil
Add new class loader tag IMC to class loader context spec which represents InMemoryDexClassLoader. A special case is required to not attempt to open its dex files as the dex location does not correspond to a real file path. This is achieved by setting load-attempted variable to 'true' when encountering IMC whilst parsing a spec. Context with IMC can still have opened dex files if it was created from an existing class loader. Bug: 72131483 Test: m test-art-host-gtest-class_loader_context_text Change-Id: Ic64065819018a1e56dee0f65405d26beb8fd7bbd
2018-11-30Revert^2 "Support shared libraries in CreateContextFromClassLoader." Nicolas Geoffray
This reverts commit 1717a493a4a0c1c3b69ecfcb58838627b4c75878. bug: 120036590 bug: 120031686 Reason for revert: Fix code to ensure ownership of dex files. Change-Id: I99fffb52b73e0a41d779a41605ddf2e9249c02e0
2018-11-30Revert "Support shared libraries in CreateContextFromClassLoader." Nicolas Geoffray
This reverts commit a66d69e884b6f9f41a8da31e6d27b498984c7fa3. bug: 120036590 bug: 120031686 Reason for revert: Fails libcore Change-Id: I6bec17b1e6c0d767c10b44572ca5f8d73c5fc37e
2018-11-29Support shared libraries in CreateContextFromClassLoader. Nicolas Geoffray
Missed this method in my previous set of shared libraries support. bug: 120036590 bug: 120031686 Test: test.py, app startup with speed-profile Change-Id: I5c1ec567cfa5452a1f510a3279a9e15125f429ba
2018-11-21Canonicalize shared libraries in ClassLoaderContext::CreateClassLoader. Nicolas Geoffray
bug:111174995 Test: class_loader_context_test Change-Id: I547b8d5660ac5cb600d09b8546062e4b054f0eb7
2018-11-20Merge "Fix parsing of shared libraries in class loader context." Nicolas Geoffray
2018-11-19Support shared libraries in ClassLoaderContext::CreateClassLoader. Nicolas Geoffray
bug: 111174995 Test: dex2oat_test, class_loader_context_test Change-Id: I482012eca408f9e064d7c3d787662376e1b0de3b
2018-11-19Fix parsing of shared libraries in class loader context. Nicolas Geoffray
The code did not take into account shared libraries depending on other shared libraries. bug: 111174995 Test: class_loader_context_test Change-Id: I0b90cfaff72b5bd7985dbe90b5e72d5988141490
2018-11-13Add missed null check in ClassLoaderContext::VerifyClassLoaderContextMatch. Nicolas Geoffray
bug: 119441748 Test: class_loader_context_test Change-Id: I68301a568eb321b42209584a3328e9a1b0fcc7ba
2018-11-01Add support for shared libaries in class loader context. Nicolas Geoffray
For example: PCL[a.dex:b.dex]{PCL[s1.dex]#PCL[s2.dex:s3.dex]};DLC[c.dex:d.dex]{DLC[s4.dex]} Rewrite the class_loader_chain_ to be a chain instead of a vector, to simplify processing and encoding of contexts. bug: 111174995 Test: class_loader_context_test, test.py Change-Id: I7c9f71b67a91b43ae534721b43dc4fdb8e0b6ec4
2018-10-23ART: Refactor for bugprone-argument-comment Andreas Gampe
Handles runtime. Bug: 116054210 Test: WITH_TIDY=1 mmma art Change-Id: Ibc0d5086809d647f0ce4df5452eb84442d27ecf0
2018-05-11Revert "Revert "Do not load app image for class collisions"" Mathieu Chartier
Fixed bug in oat file assistant to allow the special shared library marker. Bug: 77342775 Bug: 79200502 Bug: 79575750 Test: test-art-host This reverts commit 2c7e13b120926d3c3c18d649cd9849ea31b81477. Change-Id: I647f55a07e4aef8bef56fb1ad7ff23056174b135
2018-05-11Revert "Do not load app image for class collisions" Mathieu Chartier
This reverts commit d8860b42e47d48fcc47db9d0daf5a1b9432180a1. Bug: 77342775 Bug: 79200502 Bug: 79575750 Reason for revert: Some regressions in boot time. Test: test-art-host Change-Id: Id5e5844b5156d048a54011708378c7cdb0650f68
2018-05-10Do not load app image for class collisions Vladimir Marko
Even for special shared libraries that are compiled with '--class-loader-context=&', we must reject the app image if there are duplicate classes. In the case where "&" is not specified, avoid the collision check. This is safe since the class loader context check was actually run. Test: 172-app-image-twice Bug: 77342775 Bug: 79200502 Change-Id: Idc2d59166680948d4d34d0f224491f77ecad2974
2018-01-16Make ClassLoaderContextTest pass when OUT_DIR is used Alex Light
If one uses OUT_DIR when building android and it is not a subdirectory of ANDROID_BUILD_TOP then the ClassLoaderContextTest cannot be run successfully from make. We change the test so it will print an error and pass anyway in a situation to make testing easier. Test: OUT_DIR=/something/not/near/tree ./test.py --host -j50 Bug: 72042237 Change-Id: Ic55d161350f064facbdb6329c20ab53c96067a1b
2018-01-05Create dex subdirectory David Sehr
Move all the DexFile related source to a common subdirectory dex/ of runtime. Bug: 71361973 Test: make -j 50 test-art-host Change-Id: I59e984ed660b93e0776556308be3d653722f5223
2017-11-13Revert "Use real locations when opening dex files from the context" Calin Juravle
This reverts commit 821a2595e2438554424879d6cb3594810ca8e636. Reason for revert: Oat file assistant logic was updated to not use realpaths anymore. So this is no longer needed. Test: m test-art-host-gtest Change-Id: Ia63a50f60b82ec3e20606d0be852607c9d2eb26e
2017-10-11Add DexFileLoader class Mathieu Chartier
Added DexFileLoader class, moved functionality from DexFile there: - Multidex loading logic - DexFile opening logic for Zip and etc - Some other helpers Bug: 63756964 Test: test-art-host Change-Id: Ic3dfa458947d4b69912dea5cdd836e7e8f55061c
2017-09-14Update the context classpath after the dex files are opened. Calin Juravle
The classpath stored in the context maybe be out of sync with the list of opened dex files if any of the dex file is a multidex or cannot be opened. This CL ensures that OpenDexFiles updates the classpath with the dex file locations that were open. The change does not affect the current use of ClassLoaderContext. It is a preparatory step for b/62269291 Bug: 62269291 Test: m test-art-host-gtest-class_loader_context_test Change-Id: Ibe675df9b2c06a4df8189f0d72df8b4061603a0e