summaryrefslogtreecommitdiff
path: root/runtime/class_loader_context.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove '&' class loader context.Nicolas Geoffray2021-03-291-8/+0
| | | | | | | | This is now an unsupported context. Test: class_loader_context Bug: 132357300 Change-Id: I21bc6e3529944a57379845e90c7f49759db30d40
* Do not open dex files in CLC if we only need to get dexopt statusCalin Juravle2021-01-051-6/+26
| | | | | | | | | | | | | | | | | | | 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
* Remove stripped-apk related logic from CLCCalin Juravle2020-12-141-2/+1
| | | | | | | | | 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
* Search only the current class loader when checking for duplicatesCalin Juravle2020-06-251-1/+3
| | | | | | | | | | | | 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)
* Log an error when an app loads duplicate dex filesCalin Juravle2020-04-081-0/+5
| | | | | | | | | | | 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
* Introduce VMRuntime.isValidClassLoaderContextDan Zimmerman2020-02-081-0/+4
| | | | | | | | | | | | | 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
* Introduce BaseDexClassLoader.computeClassLoaderContextsNativeDan Zimmerman2020-02-081-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [art] Factor out encoding ClassLoaderContext componentsDan Zimmerman2020-01-171-0/+15
| | | | | | | | | | | 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
* Support InMemoryDexClassLoader in ClassLoaderContextDavid Brazdil2019-03-221-1/+2
| | | | | | | | | | | | | | 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
* Support FDs for class loader context dex filesDavid Brazdil2019-03-221-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert^2 "Support shared libraries in CreateContextFromClassLoader."Nicolas Geoffray2018-11-301-4/+6
| | | | | | | | | | | This reverts commit 1717a493a4a0c1c3b69ecfcb58838627b4c75878. bug: 120036590 bug: 120031686 Reason for revert: Fix code to ensure ownership of dex files. Change-Id: I99fffb52b73e0a41d779a41605ddf2e9249c02e0
* Revert "Support shared libraries in CreateContextFromClassLoader."Nicolas Geoffray2018-11-301-5/+4
| | | | | | | | | | | This reverts commit a66d69e884b6f9f41a8da31e6d27b498984c7fa3. bug: 120036590 bug: 120031686 Reason for revert: Fails libcore Change-Id: I6bec17b1e6c0d767c10b44572ca5f8d73c5fc37e
* Support shared libraries in CreateContextFromClassLoader.Nicolas Geoffray2018-11-291-4/+5
| | | | | | | | | 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
* Canonicalize shared libraries in ClassLoaderContext::CreateClassLoader.Nicolas Geoffray2018-11-211-1/+4
| | | | | | bug:111174995 Test: class_loader_context_test Change-Id: I547b8d5660ac5cb600d09b8546062e4b054f0eb7
* Add support for shared libaries in class loader context.Nicolas Geoffray2018-11-011-14/+46
| | | | | | | | | | | | 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
* Revert "Revert "Do not load app image for class collisions""Mathieu Chartier2018-05-111-7/+15
| | | | | | | | | | | | | | 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
* Revert "Do not load app image for class collisions"Mathieu Chartier2018-05-111-15/+7
| | | | | | | | | | | | | 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
* Do not load app image for class collisionsVladimir Marko2018-05-101-7/+15
| | | | | | | | | | | | | | | 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
* Add arg for overwriting class loader class pathMathieu Chartier2018-04-171-2/+9
| | | | | | | | | | | | | | 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
* Add stored class loader context optionMathieu Chartier2018-04-111-1/+5
| | | | | | | | | | | | | 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
* Update the context classpath after the dex files are opened.Calin Juravle2017-09-141-1/+7
| | | | | | | | | | | | | | | 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
* Revert "Revert "Stop using the runtime classpath in dex2oat""Calin Juravle2017-08-031-3/+7
| | | | | | | | | 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
* Revert "Stop using the runtime classpath in dex2oat"Calin Juravle2017-08-031-7/+3
| | | | | | | | 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
* Stop using the runtime classpath in dex2oatCalin Juravle2017-08-021-3/+7
| | | | | | | | | | | | 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
* Pass the class loader context to dex2oat when optimizing at runtimeCalin Juravle2017-08-021-3/+18
| | | | | | | | | | | | | 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
* Allow dex2oat to create a full class loader contextCalin Juravle2017-07-181-3/+22
| | | | | | | | | | 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
* Verify the class loader context when loading oat filesCalin Juravle2017-07-181-11/+7
| | | | | | | | | | | | | 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
* Create a class loader context starting from an existing ClassLoaderCalin Juravle2017-07-181-4/+42
| | | | | | | | | | | | | | | | 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
* Move dex files dependencies (en/de)coding to ClassLoaderContextCalin Juravle2017-07-121-2/+19
| | | | | | | | | | | | | | | | | | | | 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
* Add support for processing class loader contextsCalin Juravle2017-07-101-0/+150
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