From fa3f0782f7b1f179435f19d37e7e348cff626695 Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Wed, 21 Aug 2024 20:42:18 +0000 Subject: Remove suffix based stub matching logic This change prevents non-stub modules with stub suffix from being determined as the stub module, and instead makes the check more robust by determining the condition based on the user-hidden `Stub_contributing_api` property, which is only set for the stub submodules generated by `java_sdk_library`. Test: m nothing --no-skip-soong-tests Bug: 361179822 Change-Id: I28a599c5b4fe1e8460e60580c0535aaf19e39ba3 --- java/sdk_library_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'java/sdk_library_test.go') diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 52d4af0fd..485776b99 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -1858,3 +1858,39 @@ func TestMultipleSdkLibraryPrebuilts(t *testing.T) { android.AssertStringListContains(t, "Could not find the expected stub on classpath", inputs, tc.expectedStubPath) } } + +func TestStubLinkType(t *testing.T) { + android.GroupFixturePreparers( + prepareForJavaTest, + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ).ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern( + `module "baz" variant "android_common": compiles against system API, but dependency `+ + `"bar.stubs.system" is compiling against module API. In order to fix this, `+ + `consider adjusting sdk_version: OR platform_apis: property of the source or `+ + `target module so that target module is built with the same or smaller API set `+ + `when compared to the source.`), + ).RunTestWithBp(t, ` + java_sdk_library { + name: "foo", + srcs: ["a.java"], + sdk_version: "current", + } + java_library { + name: "bar.stubs.system", + srcs: ["a.java"], + sdk_version: "module_current", + is_stubs_module: false, + } + + java_library { + name: "baz", + srcs: ["b.java"], + libs: [ + "foo.stubs.system", + "bar.stubs.system", + ], + sdk_version: "system_current", + } + `) +} -- cgit v1.2.3-59-g8ed1b