summaryrefslogtreecommitdiff
path: root/java/hiddenapi_modular.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2021-06-30 18:25:36 +0100
committer Paul Duffin <paulduffin@google.com> 2021-06-30 19:36:52 +0100
commit3f0290ef7940c70a491dcbd4b57cabd8b2e753ef (patch)
tree3d19d31d7bcc9e9fa2a77ada44f0f5342ab5b1e2 /java/hiddenapi_modular.go
parent49387d54688b2fb4dd309f583e2da13d57a6772a (diff)
Support using java_sdk_library components in stub_libs
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. Bug: 192446466 Test: m nothing Change-Id: I9de96337f64f26e24cff040d4bbed9eecc67b1ed
Diffstat (limited to 'java/hiddenapi_modular.go')
-rw-r--r--java/hiddenapi_modular.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index 0895951ab..af124842c 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -586,6 +586,13 @@ type StubDexJarsByModule map[string]ModuleStubDexJars
// addStubDexJar adds a stub dex jar path provided by the specified module for the specified scope.
func (s StubDexJarsByModule) addStubDexJar(ctx android.ModuleContext, module android.Module, scope *HiddenAPIScope, stubDexJar android.Path) {
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
+
+ // Each named module provides one dex jar for each scope. However, in some cases different API
+ // versions of a single classes are provided by separate modules. e.g. the core platform
+ // version of java.lang.Object is provided by the legacy.art.module.platform.api module but the
+ // public version is provided by the art.module.public.api module. In those cases it is necessary
+ // to treat all those modules as they were the same name, otherwise it will result in multiple
+ // definitions of a single class being passed to hidden API processing which will cause an error.
if name == scope.nonUpdatablePrebuiltModule || name == scope.nonUpdatableSourceModule {
// Treat all *android-non-updatable* modules as if they were part of an android-non-updatable
// java_sdk_library.
@@ -606,6 +613,14 @@ func (s StubDexJarsByModule) addStubDexJar(ctx android.ModuleContext, module and
// conscrypt.module.public.api java_sdk_library which will be the case once the former has been
// migrated to a module_lib API.
name = "conscrypt.module.public.api"
+ } else if d, ok := module.(SdkLibraryComponentDependency); ok {
+ sdkLibraryName := d.SdkLibraryName()
+ if sdkLibraryName != nil {
+ // The module is a component of a java_sdk_library so use the name of the java_sdk_library.
+ // e.g. if this module is `foo.system.stubs` and is part of the `foo` java_sdk_library then
+ // use `foo` as the name.
+ name = *sdkLibraryName
+ }
}
stubDexJarsByScope := s[name]
if stubDexJarsByScope == nil {