summaryrefslogtreecommitdiff
path: root/runtime/class_loader_context.h
AgeCommit message (Collapse)Author
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-01-04Update comments for kUnsupportedClassLoaderContextEncoding. Jiakai Zhang
(partially cherry picked from commit 60bf7f88d43ea1b2694732df8a59e6ff43bc816b) Bug: 249984283 Test: N/A Change-Id: I55c344f3f178e9749b3a0b8c169c1da49d2a3c37 Merged-In: I23f651f013672defb2e61af0a744ff6e6d128bfb
2022-07-05Update ClassLoaderContext to support artd use cases. Jiakai Zhang
- Change `FlattenDexPaths` to returning `std::vector<std::string>` so that artd can use it in a more flexible way. Bug: 229268202 Test: Presubmit Change-Id: Iab0d018d4f52eea6b60f7f2d88cc56f23db6bd5c Merged-In: Iab0d018d4f52eea6b60f7f2d88cc56f23db6bd5c (cherry picked from commit 55e733f0f582f3edafa2b3bfd1168ade01813a54)
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-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
2020-01-17[art] Factor out encoding ClassLoaderContext components Dan Zimmerman
These factored out utility functions are useful to encode a partial class loader context. The end goal here is to serialize the correct classloader contexts from the runtime and send those to DexLoadReporter so that we don't depend on divergent behavior. Test: m test-art-host-gtest-class_loader_context_test Change-Id: I81a32ad7cc4aba7147ed191ccf12c9839386a9cc
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
2019-03-22Support FDs for class loader context dex files David Brazdil
When compiling secondary dex files, dex2oat/dexoptanalyzer must open all dex files in the given class loader context. However, these tools do not have the SELinux permission to open app data files and instead rely on installd to open them and pass file descriptors via command line arguments. This patch extends ClassLoaderContext::OpenDexFiles to support opening dex files from a provided list of FDs, assuming the order corresponds to the flattened class loader context. FDs can be passed to dex2oat/ dexoptanalyzer using a new '--class-loader-context-fds=' command line argument. The format is a colon-separated list of integers. dexoptanalyzer is also extended with a separate mode in which dexopt-needed analysis is not performed, only the class loader context is flattened and list of its dex files is printed to standard output as a colon-separated list of paths. This mode is enabled with '--flatten-class-loader-context' and is used by installd to obtain a list of files it should open for dex2oat/dexoptanalyzer. Bug: 126674985 Test: atest installd_dexopt_test Change-Id: I46a671c90d14ad8615508c106a88ac1ee8a4ef28
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-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-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-04-17Add arg for overwriting class loader class path Mathieu Chartier
Added stored_context srgument to EncodeContextForOatFile that overwrites the class path when non-null. This is used by the --stored-class-loader-context argument. Fixed the test. Bug: 70934104 Bug: 67345922 Test: test-art-host-gtest Change-Id: If877d8cfe9d34eeaa941e9f6df2e12539d9c4a6f
2018-04-11Add stored class loader context option Mathieu Chartier
Motivation: Enable having a different class loader context during preopt vs the one stored in the oat file. Added test. Bug: 70934104 Bug: 67345922 Test: test-art-host Change-Id: I6c0851370e0740e5f47faf25a5494022034f6fa4
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
2017-08-03Revert "Revert "Stop using the runtime classpath in dex2oat"" Calin Juravle
This reverts commit 053a84b762536144d5cae309ca5abd97766b4583. Reason for revert: Prepare the CL again to be submitted after https://chrome-internal-review.googlesource.com/c/423809 gets merged. Change-Id: I1d0e3d6bf2aa16249b2d0146acd9c81149924c00
2017-08-03Revert "Stop using the runtime classpath in dex2oat" Calin Juravle
This reverts commit 84f82b9972ec29bd05b1575ae6d638255be2f285. Reason for revert: I submitted this to ealrly. It needs to be submitted after https://android-review.googlesource.com/c/450390 gets merged Change-Id: I91e6259b61d72a48a1d18e62f53ef82f18692930
2017-08-02Stop using the runtime classpath in dex2oat Calin Juravle
Use only --class-loader-context to infer the classpath that should be used for compilation. The tests and benchmarks no longer rely on --runtime-arg --classpath being passed to dex2oat. Bug: 36044779 Test: m test-art-host Change-Id: Iba4cb3489f4a1a4a421071e1889d806d6c1d0738
2017-08-02Pass the class loader context to dex2oat when optimizing at runtime Calin Juravle
Until now we always passed the special shared library symbol "&" when we called dex2oat at runtime without an explicit class path. This CL changes that and passes the class loader context inferred from the runtime class loaders to dex2oat. If any of the runtime class loaders is not supported we continue to pass the special library symbol. Bug: 38138251 Test: m test-art-host Change-Id: Ica43ee8a3f36dab2d9ed0e634a9f6341379c8e1c
2017-07-18Allow dex2oat to create a full class loader context Calin Juravle
We previously checked that dex2oat sees only a single class loader. This CL removes the restriction and enables dex2oat to create and compile with a full class loader context. Test: m test-art-host Bug: 38138251 Change-Id: I03e75a75757995ce8ce3addf0bc0a708e18ac050
2017-07-18Verify the class loader context when loading oat files Calin Juravle
Previously, the oat_file_manager would expect and perform validation on a simple classpath: a list of dex files separated by ':'. This is no longer enough since the oat file may encode a chain of class loaders now. The CL moves the validation logic in ClassLoaderContext and extends it to verify the complete chain of class loaders. Test: m test-art-host Bug: 38138251 Change-Id: I8ac9c65db1a14909aaecb04fa7a7115ddedc673f
2017-07-18Create a class loader context starting from an existing ClassLoader Calin Juravle
Extend ClassLoaderContext to be able to generate a context from an existing class loader. This will be used in extending the duplicate class check to cover DelegateLastClassLoaders. Most of the functionality is migrated from OatFileManager with some cleanups consisting of extra docs and more conservative checks on the integrity of the class loader chain. Test: m test-art-host Bug: 38138251 Change-Id: If7c18cb75bfc9e6784676f96a666bf13b04c8b8b
2017-07-12Move dex files dependencies (en/de)coding to ClassLoaderContext Calin Juravle
Encode the full class loader context in the oat file (rather than just a list of dex files). The context encoding matches the format used by dex2oat with the addition of checksums. Temporarily assert that at decoding time we are operating on a PathClassLoader until the checking logic covers all supported cases. Also, bump the version of the oat file because the format of the classpath key has changed. This is a transition step to minimize the size of follow up changes. Test: m test-art-host Bug: 38138251 Change-Id: I9ec0cfe092ce1afccb741a36e737896880d5f1d2
2017-07-10Add support for processing class loader contexts Calin Juravle
Initial support for recognizing the class loader contexts. In order to correctly compile dex files which at runtime are loaded with a non-trivial class loader chain we need to make dex2oat aware of the precise runtime context. This CL adds the infrastructure to process arbitrary and arbitrary chain of class loaders. ClassLoaderContext is able to parse a class loader spec from a string and create the runtime structure based on it. The integration with dex2oat and oat file assistant will follow up. The string specification looks like "PCL[lib1.dex:lib2.dex];DLC[lib3.dex]" It describes how the class loader chain should be build in order to ensure classes are resolved during dex2aot as they would be resolved at runtime. This spec will be encoded in the oat file. If at runtime the dex file will be loaded in a different context, the oat file will be rejected. The chain is interpreted in the natural 'parent order', meaning that class loader 'i+1' will be the parent of class loader 'i'. The compilation sources will be added to the classpath of the last class loader. This allows the compiled dex files to be loaded at runtime in a class loader that contains other dex files as well (e.g. shared libraries). Note that we accept chains for which the source dex files specified with --dex-file are found in the classpath. In this case the source dex files will be removed from the any class loader's classpath possibly resulting in empty class loaders. * This is the first CL, which adds the infrastructure for processing a class loader context. Currently it CHECKS that only a single PathClassLoader is created. Test: m test-art-host Bug: 38138251 Change-Id: I312aa12b5732288f3c1df4746b5775a32e0bfb04