diff options
Diffstat (limited to 'java')
| -rwxr-xr-x | java/app.go | 7 | ||||
| -rw-r--r-- | java/java.go | 29 | ||||
| -rw-r--r-- | java/sdk.go | 8 | ||||
| -rw-r--r-- | java/sdk_test.go | 9 | ||||
| -rw-r--r-- | java/testing.go | 1 |
5 files changed, 51 insertions, 3 deletions
diff --git a/java/app.go b/java/app.go index 6e0ffeb67..9503ec455 100755 --- a/java/app.go +++ b/java/app.go @@ -583,6 +583,13 @@ func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string { return String(a.overridableAppProperties.Certificate) } +func (a *AndroidApp) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { + if IsJniDepTag(ctx.OtherModuleDependencyTag(dep)) { + return true + } + return a.Library.DepIsInSameApex(ctx, dep) +} + // For OutputFileProducer interface func (a *AndroidApp) OutputFiles(tag string) (android.Paths, error) { switch tag { diff --git a/java/java.go b/java/java.go index ed3dca9e0..c94ea8293 100644 --- a/java/java.go +++ b/java/java.go @@ -757,9 +757,12 @@ func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer type linkType int const ( + // TODO(jiyong) rename these for better readability. Make the allowed + // and disallowed link types explicit javaCore linkType = iota javaSdk javaSystem + javaModule javaPlatform ) @@ -789,6 +792,10 @@ func (m *Module) getLinkType(name string) (ret linkType, stubs bool) { return javaSdk, true case ver.kind == sdkPublic: return javaSdk, false + case name == "android_module_lib_stubs_current": + return javaModule, true + case ver.kind == sdkModule: + return javaModule, false case ver.kind == sdkPrivate || ver.kind == sdkNone || ver.kind == sdkCorePlatform: return javaPlatform, false case !ver.valid(): @@ -824,11 +831,17 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to linkTypeContext, } break case javaSystem: - if otherLinkType == javaPlatform { + if otherLinkType == javaPlatform || otherLinkType == javaModule { ctx.ModuleErrorf("compiles against system API, but dependency %q is compiling against private API."+commonMessage, ctx.OtherModuleName(to)) } break + case javaModule: + if otherLinkType == javaPlatform { + ctx.ModuleErrorf("compiles against module API, but dependency %q is compiling against private API."+commonMessage, + ctx.OtherModuleName(to)) + } + break case javaPlatform: // no restriction on link-type break @@ -1704,8 +1717,10 @@ func (j *Module) hasCode(ctx android.ModuleContext) bool { func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { depTag := ctx.OtherModuleDependencyTag(dep) - // dependencies other than the static linkage are all considered crossing APEX boundary - return depTag == staticLibTag + // Dependencies other than the static linkage are all considered crossing APEX boundary + // Also, a dependency to an sdk member is also considered as such. This is required because + // sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator. + return depTag == staticLibTag || j.IsInAnySdk() } func (j *Module) Stem() string { @@ -2393,6 +2408,14 @@ func (j *Import) SrcJarArgs() ([]string, android.Paths) { return nil, nil } +func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { + depTag := ctx.OtherModuleDependencyTag(dep) + // dependencies other than the static linkage are all considered crossing APEX boundary + // Also, a dependency to an sdk member is also considered as such. This is required because + // sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator. + return depTag == staticLibTag || j.IsInAnySdk() +} + // Add compile time check for interface implementation var _ android.IDEInfo = (*Import)(nil) var _ android.IDECustomizedModuleName = (*Import)(nil) diff --git a/java/sdk.go b/java/sdk.go index f388358e5..1c047a353 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -71,6 +71,7 @@ const ( sdkPublic sdkSystem sdkTest + sdkModule sdkPrivate ) @@ -91,6 +92,8 @@ func (k sdkKind) String() string { return "core" case sdkCorePlatform: return "core_platform" + case sdkModule: + return "module" default: return "invalid" } @@ -256,6 +259,8 @@ func sdkSpecFrom(str string) sdkSpec { kind = sdkSystem case "test": kind = sdkTest + case "module": + kind = sdkModule default: return sdkSpec{sdkInvalid, sdkVersionNone, str} } @@ -382,6 +387,9 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep return toModule("android_test_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx)) case sdkCore: return toModule("core.current.stubs", "", nil) + case sdkModule: + // TODO(146757305): provide .apk and .aidl that have more APIs for modules + return toModule("android_module_lib_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx)) default: panic(fmt.Errorf("invalid sdk %q", sdkVersion.raw)) } diff --git a/java/sdk_test.go b/java/sdk_test.go index 9cabd7772..c815fe3c1 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -211,6 +211,15 @@ func TestClasspath(t *testing.T) { java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, aidl: "-pprebuilts/sdk/29/public/framework.aidl", }, + { + + name: "module_current", + properties: `sdk_version: "module_current",`, + bootclasspath: []string{"android_module_lib_stubs_current", "core-lambda-stubs"}, + system: "core-current-stubs-system-modules", + java9classpath: []string{"android_module_lib_stubs_current"}, + aidl: "-p" + buildDir + "/framework.aidl", + }, } for _, testcase := range classpathTestcases { diff --git a/java/testing.go b/java/testing.go index c409a46eb..8f979c73e 100644 --- a/java/testing.go +++ b/java/testing.go @@ -146,6 +146,7 @@ func GatherRequiredDepsForTest() string { "android_stubs_current", "android_system_stubs_current", "android_test_stubs_current", + "android_module_lib_stubs_current", "core.current.stubs", "core.platform.api.stubs", "kotlin-stdlib", |