Merge "Add a unit test for class loader context with java_sdk_library impl lib" into main am: e2aeb50e49

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3272612

Change-Id: Ib533469e7a619b2edcbe105cf096d8e03857bfbc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2024-09-18 23:59:12 +00:00
committed by Automerger Merge Worker

View File

@@ -11656,3 +11656,110 @@ func TestPrebuiltStubNoinstall(t *testing.T) {
) )
}) })
} }
func TestSdkLibraryTransitiveClassLoaderContext(t *testing.T) {
// This test case tests that listing the impl lib instead of the top level java_sdk_library
// in libs of android_app and java_library does not lead to class loader context device/host
// path mismatch errors.
android.GroupFixturePreparers(
prepareForApexTest,
android.PrepareForIntegrationTestWithAndroid,
PrepareForTestWithApexBuildComponents,
android.FixtureModifyEnv(func(env map[string]string) {
env["DISABLE_CONTAINER_CHECK"] = "true"
}),
withFiles(filesForSdkLibrary),
android.FixtureMergeMockFs(android.MockFS{
"system/sepolicy/apex/com.android.foo30-file_contexts": nil,
}),
).RunTestWithBp(t, `
apex {
name: "com.android.foo30",
key: "myapex.key",
updatable: true,
bootclasspath_fragments: [
"foo-bootclasspath-fragment",
],
java_libs: [
"bar",
],
apps: [
"bar-app",
],
min_sdk_version: "30",
}
apex_key {
name: "myapex.key",
public_key: "testkey.avbpubkey",
private_key: "testkey.pem",
}
bootclasspath_fragment {
name: "foo-bootclasspath-fragment",
contents: [
"framework-foo",
],
apex_available: [
"com.android.foo30",
],
hidden_api: {
split_packages: ["*"]
},
}
java_sdk_library {
name: "framework-foo",
srcs: [
"A.java"
],
unsafe_ignore_missing_latest_api: true,
apex_available: [
"com.android.foo30",
],
compile_dex: true,
sdk_version: "core_current",
shared_library: false,
}
java_library {
name: "bar",
srcs: [
"A.java"
],
libs: [
"framework-foo.impl",
],
apex_available: [
"com.android.foo30",
],
sdk_version: "core_current",
}
java_library {
name: "baz",
srcs: [
"A.java"
],
libs: [
"bar",
],
sdk_version: "core_current",
}
android_app {
name: "bar-app",
srcs: [
"A.java"
],
libs: [
"baz",
"framework-foo.impl",
],
apex_available: [
"com.android.foo30",
],
sdk_version: "core_current",
min_sdk_version: "30",
manifest: "AndroidManifest.xml",
}
`)
}