summaryrefslogtreecommitdiff
path: root/java/bootclasspath_fragment_test.go
AgeCommit message (Collapse)Author
2021-07-01Support using java_sdk_library components in stub_libsPaul Duffin
Previously, if a bootclasspath_fragment had both a java_sdk_library module and one of its components in stub_libs properties they would be treated as separate modules instead of simply different APIs from the same module. That would result in them both providing stub dex jars to "hiddenapi list" which would fail because it found duplicate definitions of the same class. e.g. Specifying something like this: api: { stub_libs: [ "art.module.public.api", ], }, core_platform_api: { stub_libs: [ "art.module.public.api.stubs.module_lib", ], }, would cause "hiddenapi list" to fail because it would have been passed paths to two dex jars (actually the same dex jar but that does not matter) each of which defined the same class, e.g. java.lang.Object. This change treats the "art.module.public.api.stubs.module_lib" and "art.module.public.api" modules as being the same for the purposes of hidden API processing. (cherry picked from commit 3f0290ef7940c70a491dcbd4b57cabd8b2e753ef) Bug: 192446466 Test: m nothing Merged-In: I9de96337f64f26e24cff040d4bbed9eecc67b1ed Change-Id: I9e1cb82bea96022faaec98edc0c9ea7eac6204b0
2021-06-28Calculate widest stub dex jars per modulePaul Duffin
Previously, the stub dex jars for each HiddenAPIScope was created by merging the stub dex jars provided by each module for that scope. Then the widest stub dex jars were chosen. So, if module A provided public, system and test stub dex jars and module B provided only public then the stub dex jars for each scope would be: * public -> A,B * system -> A * test -> A So, the widest API scope for which there are stub dex jars is "test" and so the widest stub dex jars would just come from module A and not module B. So, when "hiddenapi list" is run for module C which depends on modules A and B it only gets given stub dex jars for module A which means that it cannot resolve all the types that C may use which can lead to incorrect flags being generated. This change does not merge the stub dex jars from each module together and instead keeps them separate by module. The widest stub dex jars list is constructed by asking each module in turn for their widest stub dex jars. e.g. Given the above example we would have: Module A: * public * system * test <- widest Module B: * public <- widest So, the widest stub dex jars will be A's test and B's public stub dex jars. Bug: 179354495 Test: m out/soong/hiddenapi-flags.csv - make sure that this does not change the file. Merged-In: Ib137825ebffe94b2bf220732bae6077f7b7ac6db Change-Id: Ib137825ebffe94b2bf220732bae6077f7b7ac6db (cherry picked from commit 280a31aac39697a069f2f2f2ee471ffafb52d2a3)
2021-06-28Add test to show issues with widest stub dex jarsPaul Duffin
The widest stub dex jars should include the widest stub dex jars provided by each module. So, if module A has public, system and test and module B has only public then the widest stub dex jars should include module A's test and module B's public stub dex jars. Instead, they just include module A's test. That behaviour is needed so that when the "hiddenapi list" tool is run against a module C that it is passed stub dex jars from both module A and module B so that any references to the types provided by those APIs can be resolved. A follow up change will fix this issue. Bug: 179354495 Test: m nothing Merged-In: Ibd31964e8d2a33fa92fbd0b800c9fe054ee359c7 Change-Id: Ibd31964e8d2a33fa92fbd0b800c9fe054ee359c7 (cherry picked from commit d2b1e0ca92cb3f2c4b98efffd5968057af4e4320)
2021-06-25Add HiddenAPIScope to replace use of SdkKindPaul Duffin
Previously, the hidden API processing used SdkKind to identify the API scopes, e.g. public, system, etc. that are of interest for hidden API processing. Unfortunately, there is a mismatch between the SdkKind and what hidden API processing needs. e.g. SdkKind includes values that are not used by hidden API processing and hidden API processing needs additional API scope specific information not provided by SdkKind. The apiScope struct used in sdk_library.go is also not a suitable representation for similar reasons. This change adds the HiddenAPIScope (following a similar approach as apiScope) that rectifies that and uses it as a replacement for SdkKind in most parts of the hidden API processing. The SdkKind is still used for retrieving information from java_sdk_library[_import] modules. Follow up changes will extend the HiddenAPIScope with more information. Bug: 179354495 Test: m out/soong/hiddenapi/hiddenapi-flags.csv - make sure that this change has no effect on the generated flags. Merged-In: I97968f58535121652852b8d25217aa288afd2bfd Change-Id: I97968f58535121652852b8d25217aa288afd2bfd (cherry picked from commit 31fad800a7a44ef2edda5d4051335f28d514139a)
2021-05-25Tighten bootclasspath_fragment property validationPaul Duffin
Previously, due to legacy reasons, the property validation did not require a contents property and allowed the image_name to be either "art" or "boot". Those reasons no longer apply and so this change requires a contents property and only allows the image_name to be set to "art" if specified. Bug: 177892522 Test: m nothing Merged-In: I8855d6e5365ef0b55490e90e7b6c0081cf070ee5 Change-Id: I8855d6e5365ef0b55490e90e7b6c0081cf070ee5 (cherry picked from commit 8018e50ddb141dea7891918c4178a7a394a788d8)
2021-05-24Support hidden API processing for fragments with dependenciesPaul Duffin
Previously, a bootclasspath_fragment that depended on classes provided by another bootclasspath_fragment did not support hidden API processing as it would not supply information about those dependencies. This change adds support for that as follows. Each fragment: 1. Exports the transitive sets of stub dex jars for each of the public, system, test and core_platform APIs (where relevant). 2. Adds dependencies onto its dependent fragments. 3. Retrieves the API stubs dex jars from its dependent fragments and passes them to the "hiddenapi list" tool which will use them to resolve dependencies but will not output them to the generated flags. Once the flags are generated the existing encoding functionality encodes the flags into the dex files of the bootclasspath_fragment's content modules which are then packaged into the apex. Bug: 179354495 Test: m com.android.sdkext - verify that this does not change the contents of the apex files Merged-In: I3e82a6dbb437f1e417e5d7e25aeb212e378603d0 Change-Id: I3e82a6dbb437f1e417e5d7e25aeb212e378603d0 (cherry picked from commit f1b358cb5764039ff7502e9f73ad0abfdc91c7aa)
2021-05-24Remove bootclasspathApiInfoPaul Duffin
Previously, the bootclasspathApiInfo was only used for tests and follow up changes will need to provide the stub dex jars. This change moves the stubJarsByKind into HiddenAPIInfo and removes bootclasspathApiInfo and the corresponding provider. Bug: 179354495 Test: m nothing Merged-In: I5459c56de561c053ed671dc9d5cb3ee4820c0ee8 Change-Id: I5459c56de561c053ed671dc9d5cb3ee4820c0ee8 (cherry picked from commit 18cf19745e2fffb184a7b42f50609ea98d4adb1d)
2021-05-14Use java_sdk_library in bootclasspath_fragment contents as stubsPaul Duffin
A java_sdk_library specified in the bootclasspath_fragment contents must be providing APIs for the bootclasspath_fragment and so must be treated as if they were specified in the stub_libs. This avoids having to specify them in both contents and stub_libs. Bug: 179354495 Test: m nothing Change-Id: I535065ee1a79b439e2676f35e06a75d4626adcaf
2021-05-14Disallow shared libraries in bootclasspath_fragment contentsPaul Duffin
Bug: 177892522 Test: m nothing Change-Id: I78c8ef8664ec1eb0fe3456a2de2cb956162ca0da
2021-04-28Add stub_libs properties to bootclasspath_fragment snapshotPaul Duffin
Bug: 177892522 Test: m nothing Change-Id: I7644122c4abed8e8bc2cc7b58f408bee3bdc91f6
2021-04-28Add support for specifying api provided by bootclasspath_fragmentPaul Duffin
The hidden API processing needs access to dex stub jars for the API scopes provided by the bootclasspath_fragment so that it can mark the corresponding dex members as being part of that API. This change adds the ability to specify the modules that provide those jars, resolve the modules to dex jar stubs and make them available for other modules and tests to use. While the stubs are only needed for hidden API at the moment these were not added to the hidden_api properties section as there are other parts of the build that may need to access the stubs in future, e.g. api fingerprint and aidl generation. The stubs properties can be affected by coverage as when coverage is enabled the jacoco-stubs needs adding to the list, just like how jacocoagent is added to the contents. Bug: 177892522 Test: m nothing Change-Id: I31097d1ca45c84adeba4cbb38f693698cb289e99
2021-04-26Allow contents and image_name to be specified togetherPaul Duffin
Previously, only one of the contents or image_name properties could be specified at once which meant that there was no way to create a prebuilt which lists its fixed contents while at the same time allowing it to check that that the contents matched what the build configuration required. e.g. a prebuilt_bootclasspath_fragment that had image_name: "art", could not list its contents and also check that those contents matched the ART_APEX_JARS which the build configuration required. This change allows contents and image_name to be specified together and adds a check to make sure that the contents are consistent with the configuration appropriate to the image_name. The check is only performed for modules that are active so that a prebuilt_bootclasspath_fragment which was created without coverage enabled (the default) would not cause a build failure in a coverage build unless it was preferred. Bug: 177892522 Test: m nothing Change-Id: Ie601f29f707b3f6030fa7d252afa2c4826cc9f8e
2021-04-26Add coverage specific properties to bootclasspath_fragmentPaul Duffin
This allows a bootclasspath_fragment (specifically the art-bootclasspath-fragment) to specify additional contents to be appended when coverage is enabled. The art-bootclasspath-fragment will use this to add jacocoagent to its contents to ensure that it is always consistent with the configuration. Bug: 177892522 Test: m nothing Change-Id: I50d05fe5e0e9b8c14bdf3dfd63bba0ac97e31d48
2021-04-23Rename BootImageModule to BootclasspathFragmentModulePaul Duffin
Also renames files, tests, module types in a similar fashion. There are still some references to image and boot image. They are kept for the following reasons: * image_name - this is the name of an ART boot image, i.e. the collection of .art/.oat/.vdex files. * BootImageInfo - again this is related to the ART boot image. * .../art_boot_images/... paths - ditto. Bug: 177892522 Test: m nothing Change-Id: Ie1f4738061d131fee75de48bc26a7601481bad4d