From 08f476bf831850e7e1a86d56d72b518007783045 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Wed, 7 Apr 2021 15:32:19 +0100 Subject: [PATCH] Fix bug in sdk_library string matching - The public stubs were being matched against the string ".stubs.public" which was never the suffix that these stubs used - Remove obsolete naming pattern matching Test: m Change-Id: I1f7bd54e4629f42e34fb3c09828d8853813ba2a7 --- java/sdk_library.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index 37b8d9f62..5349a87e0 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -201,8 +201,12 @@ func initApiScope(scope *apiScope) *apiScope { return scope } +func (scope *apiScope) stubsLibraryModuleNameSuffix() string { + return ".stubs" + scope.moduleSuffix +} + func (scope *apiScope) stubsLibraryModuleName(baseName string) string { - return baseName + ".stubs" + scope.moduleSuffix + return baseName + scope.stubsLibraryModuleNameSuffix() } func (scope *apiScope) stubsSourceModuleName(baseName string) string { @@ -1684,16 +1688,20 @@ var _ sdkLibraryComponentNamingScheme = (*defaultNamingScheme)(nil) func moduleStubLinkType(name string) (stub bool, ret sdkLinkType) { // This suffix-based approach is fragile and could potentially mis-trigger. // TODO(b/155164730): Clean this up when modules no longer reference sdk_lib stubs directly. - if strings.HasSuffix(name, ".stubs.public") || strings.HasSuffix(name, "-stubs-publicapi") { + if strings.HasSuffix(name, apiScopePublic.stubsLibraryModuleNameSuffix()) { + if name == "hwbinder.stubs" || name == "libcore_private.stubs" { + // Due to a previous bug, these modules were not considered stubs, so we retain that. + return false, javaPlatform + } return true, javaSdk } - if strings.HasSuffix(name, ".stubs.system") || strings.HasSuffix(name, "-stubs-systemapi") { + if strings.HasSuffix(name, apiScopeSystem.stubsLibraryModuleNameSuffix()) { return true, javaSystem } - if strings.HasSuffix(name, ".stubs.module_lib") || strings.HasSuffix(name, "-stubs-module_libs_api") { + if strings.HasSuffix(name, apiScopeModuleLib.stubsLibraryModuleNameSuffix()) { return true, javaModule } - if strings.HasSuffix(name, ".stubs.test") { + if strings.HasSuffix(name, apiScopeTest.stubsLibraryModuleNameSuffix()) { return true, javaSystem } return false, javaPlatform