From e87b03d1bb837dfac724376447a0e07a4ef8ccc3 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Mon, 21 Dec 2020 15:29:34 +0000 Subject: [PATCH] Set previous_api correctly for java_sdk_library Metalava used this attribute to potentially re-write some nullness annotations from @Nullable to @RecentlyNonNull, and not doing so can cause problems when compiling kotlin. Bug: 176092452 Test: m art.module.public.api.stubs && \ rm -rf /tmp/lib && \ unzip -qd /tmp/lib art.module.public.api.stubs.jar && \ javap -v /tmp/lib/java/util/concurrent/ConcurrentHashMap.class | \ grep Recently Change-Id: I9012798f27e39d9a53dbcf0976548f6cec2d3150 --- java/droiddoc.go | 4 ++++ java/sdk_library.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/java/droiddoc.go b/java/droiddoc.go index cbca12a76..f54b51711 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -1082,6 +1082,10 @@ func (d *Droidstubs) DepsMutator(ctx android.BottomUpMutatorContext) { // If requested clear any properties that provide information about the latest version // of an API and which reference non-existent modules. if Bool(d.properties.Check_api.Ignore_missing_latest_api) { + previousApi := android.SrcIsModule(String(d.properties.Previous_api)) + if previousApi != "" && !ctx.OtherModuleExists(previousApi) { + d.properties.Previous_api = nil + } ignoreMissingModules(ctx, &d.properties.Check_api.Last_released) // If the new_since references a module, e.g. :module-latest-api and the module diff --git a/java/sdk_library.go b/java/sdk_library.go index f279b95b6..057e14bac 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1271,6 +1271,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC Merge_annotations_dirs []string Merge_inclusion_annotations_dirs []string Generate_stubs *bool + Previous_api *string Check_api struct { Current ApiToCheck Last_released ApiToCheck @@ -1363,6 +1364,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC if !apiScope.unstable { // check against the latest released API latestApiFilegroupName := proptools.StringPtr(module.latestApiFilegroupName(apiScope)) + props.Previous_api = latestApiFilegroupName props.Check_api.Last_released.Api_file = latestApiFilegroupName props.Check_api.Last_released.Removed_api_file = proptools.StringPtr( module.latestRemovedApiFilegroupName(apiScope))