summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorInseob Kim <inseob@google.com>2019-12-09 18:15:47 +0900
committerInseob Kim <inseob@google.com>2019-12-19 09:35:23 +0900
commitac1e986c55f1ed98d36a267bef5bc22c3bbd1716 (patch)
tree2cd41ae843a48d07697b2806b43cfa007b195057 /java/java.go
parenta1682631ebb91342e6de421799f929c442c41c03 (diff)
Create public stub for platform's sysprop_library
Java modules using SystemAPI can now link against platform owned sysprop_library with public stub. This allows modules to use platform's public sysprops (which should be regarded as an API) without any hidden API usages, if using dynamic linking and boot class path. This doesn't affect any vendor or odm owned sysprop_library. Bug: 141246285 Bug: 145167888 Test: m Change-Id: I99824fb24a75cc8282211c2ad6c6296ae9fca393
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go32
1 files changed, 30 insertions, 2 deletions
diff --git a/java/java.go b/java/java.go
index d8db5f8a4..2d97b7f3b 100644
--- a/java/java.go
+++ b/java/java.go
@@ -585,8 +585,36 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
}
}
- ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
- ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...)
+ syspropPublicStubs := syspropPublicStubs(ctx.Config())
+
+ // rewriteSyspropLibs validates if a java module can link against platform's sysprop_library,
+ // and redirects dependency to public stub depending on the link type.
+ rewriteSyspropLibs := func(libs []string, prop string) []string {
+ // make a copy
+ ret := android.CopyOf(libs)
+
+ for idx, lib := range libs {
+ stub, ok := syspropPublicStubs[lib]
+
+ if !ok {
+ continue
+ }
+
+ linkType, _ := j.getLinkType(ctx.ModuleName())
+ if linkType == javaSystem {
+ ret[idx] = stub
+ } else if linkType != javaPlatform {
+ ctx.PropertyErrorf("sdk_version",
+ "can't link against sysprop_library %q from a module using public or core API",
+ lib)
+ }
+ }
+
+ return ret
+ }
+
+ ctx.AddVariationDependencies(nil, libTag, rewriteSyspropLibs(j.properties.Libs, "libs")...)
+ ctx.AddVariationDependencies(nil, staticLibTag, rewriteSyspropLibs(j.properties.Static_libs, "static_libs")...)
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), pluginTag, j.properties.Plugins...)
ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), exportedPluginTag, j.properties.Exported_plugins...)