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
This commit is contained in:
Anton Hansson 2020-12-21 15:29:34 +00:00
parent 8bfb63c5a9
commit e87b03d1bb
2 changed files with 6 additions and 0 deletions

View File

@ -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

View File

@ -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))