From 1e7438524b7e28c5f58c6ab380a53777c221dc70 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 28 Oct 2019 11:37:20 -0700 Subject: Make javaVersion an enum Remove the hardcoded checks against "1.9" by making javaVersion an enum and implementing javaVersion.usesJavaModules(). Test: TestClasspath Change-Id: I559eeb1f45880bb8177269c6d977ee4dfbadce57 --- java/java.go | 68 +++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 21 deletions(-) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 9ed76214f..9aa75b2fc 100644 --- a/java/java.go +++ b/java/java.go @@ -865,8 +865,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { return deps } -func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sdkContext) string { - var ret string +func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sdkContext) javaVersion { v := sdkContext.sdkVersion() // For PDK builds, use the latest SDK version instead of "current" if ctx.Config().IsPdkBuild() && @@ -884,41 +883,69 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd ctx.PropertyErrorf("sdk_version", "%s", err) } if javaVersion != "" { - ret = normalizeJavaVersion(ctx, javaVersion) + return normalizeJavaVersion(ctx, javaVersion) } else if ctx.Device() && sdk <= 23 { - ret = "1.7" + return JAVA_VERSION_7 } else if ctx.Device() && sdk <= 29 { - ret = "1.8" + return JAVA_VERSION_8 } else if ctx.Device() && sdkContext.sdkVersion() != "" && sdkContext.sdkVersion() != "none" && sdkContext.sdkVersion() != "core_platform" && sdk == android.FutureApiLevel { // TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current" - ret = "1.8" + return JAVA_VERSION_8 } else { - ret = "1.9" + return JAVA_VERSION_9 } +} + +type javaVersion int + +const ( + JAVA_VERSION_UNSUPPORTED = 0 + JAVA_VERSION_6 = 6 + JAVA_VERSION_7 = 7 + JAVA_VERSION_8 = 8 + JAVA_VERSION_9 = 9 +) - return ret +func (v javaVersion) String() string { + switch v { + case JAVA_VERSION_6: + return "1.6" + case JAVA_VERSION_7: + return "1.7" + case JAVA_VERSION_8: + return "1.8" + case JAVA_VERSION_9: + return "1.9" + default: + return "unsupported" + } } -func normalizeJavaVersion(ctx android.ModuleContext, javaVersion string) string { +// Returns true if javac targeting this version uses system modules instead of a bootclasspath. +func (v javaVersion) usesJavaModules() bool { + return v >= 9 +} + +func normalizeJavaVersion(ctx android.BaseModuleContext, javaVersion string) javaVersion { switch javaVersion { case "1.6", "6": - return "1.6" + return JAVA_VERSION_6 case "1.7", "7": - return "1.7" + return JAVA_VERSION_7 case "1.8", "8": - return "1.8" + return JAVA_VERSION_8 case "1.9", "9": - return "1.9" + return JAVA_VERSION_9 case "10", "11": ctx.PropertyErrorf("java_version", "Java language levels above 9 are not supported") - return "unsupported" + return JAVA_VERSION_UNSUPPORTED default: ctx.PropertyErrorf("java_version", "Unrecognized Java language level") - return "unrecognized" + return JAVA_VERSION_UNSUPPORTED } } @@ -931,7 +958,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB // javac flags. javacFlags := j.properties.Javacflags - if flags.javaVersion == "1.9" { + if flags.javaVersion.usesJavaModules() { javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...) } if ctx.Config().MinimizeJavaDebugInfo() { @@ -963,9 +990,8 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB flags.processor = strings.Join(deps.processorClasses, ",") - if len(flags.bootClasspath) == 0 && ctx.Host() && flags.javaVersion != "1.9" && - decodeSdkDep(ctx, sdkContext(j)).hasStandardLibs() && - inList(flags.javaVersion, []string{"1.6", "1.7", "1.8"}) { + if len(flags.bootClasspath) == 0 && ctx.Host() && !flags.javaVersion.usesJavaModules() && + decodeSdkDep(ctx, sdkContext(j)).hasStandardLibs() { // Give host-side tools a version of OpenJDK's standard libraries // close to what they're targeting. As of Dec 2017, AOSP is only // bundling OpenJDK 8 and 9, so nothing < 8 is available. @@ -989,7 +1015,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB } } - if j.properties.Patch_module != nil && flags.javaVersion == "1.9" { + if j.properties.Patch_module != nil && flags.javaVersion.usesJavaModules() { // Manually specify build directory in case it is not under the repo root. // (javac doesn't seem to expand into symbolc links when searching for patch-module targets, so // just adding a symlink under the root doesn't help.) @@ -1022,7 +1048,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { deps := j.collectDeps(ctx) flags := j.collectBuilderFlags(ctx, deps) - if flags.javaVersion == "1.9" { + if flags.javaVersion.usesJavaModules() { j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...) } srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs) -- cgit v1.2.3-59-g8ed1b From 6d8d8c6a91dad242bbe406b2b055728b196fe8de Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 28 Oct 2019 15:10:03 -0700 Subject: Remove special case for sdk_version: "none" The dependency handling for sdk_version: "none" (which propagated to !sdkDep.hasStandardLibs()) was very similar to the normal useModule case. Combine the cases by making decodeSdkDep set useModule: true and put the system modules in modules for the sdk_version: "none" case. Test: TestClasspath Change-Id: Icc9ff4d43a38da25cc0e3628be95951d61773ad5 --- java/droiddoc.go | 20 +++++++------------- java/java.go | 29 ++++++++++++----------------- java/sdk.go | 7 +++++-- 3 files changed, 24 insertions(+), 32 deletions(-) (limited to 'java/java.go') diff --git a/java/droiddoc.go b/java/droiddoc.go index 32758f6ff..714412c77 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -422,21 +422,15 @@ func (j *Javadoc) targetSdkVersion() string { func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) { if ctx.Device() { sdkDep := decodeSdkDep(ctx, sdkContext(j)) - if sdkDep.hasStandardLibs() { - if sdkDep.useDefaultLibs { - ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...) - ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules) - if sdkDep.hasFrameworkLibs() { - ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...) - } - } else if sdkDep.useModule { - ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) - ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...) + if sdkDep.useDefaultLibs { + ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...) + ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules) + if sdkDep.hasFrameworkLibs() { + ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...) } - } else if sdkDep.systemModules != "" { - // Add the system modules to both the system modules and bootclasspath. + } else if sdkDep.useModule { + ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...) ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) - ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.systemModules) } } diff --git a/java/java.go b/java/java.go index 9aa75b2fc..4fc5a6f58 100644 --- a/java/java.go +++ b/java/java.go @@ -524,26 +524,21 @@ func (j *Module) targetSdkVersion() string { func (j *Module) deps(ctx android.BottomUpMutatorContext) { if ctx.Device() { sdkDep := decodeSdkDep(ctx, sdkContext(j)) - if sdkDep.hasStandardLibs() { - if sdkDep.useDefaultLibs { - ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...) - ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules) - if sdkDep.hasFrameworkLibs() { - ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...) - } - } else if sdkDep.useModule { - ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) - ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...) - if j.deviceProperties.EffectiveOptimizeEnabled() { - ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...) - ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...) - } + if sdkDep.useDefaultLibs { + ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...) + ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules) + if sdkDep.hasFrameworkLibs() { + ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...) } - } else if sdkDep.systemModules != "" { - // Add the system modules to both the system modules and bootclasspath. + } else if sdkDep.useModule { + ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...) ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) - ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.systemModules) + if j.deviceProperties.EffectiveOptimizeEnabled() && sdkDep.hasStandardLibs() { + ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...) + ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...) + } } + if ctx.ModuleName() == "android_stubs_current" || ctx.ModuleName() == "android_system_stubs_current" || ctx.ModuleName() == "android_test_stubs_current" { diff --git a/java/sdk.go b/java/sdk.go index c6a9a73c8..d8584d2b0 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -192,13 +192,16 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { ctx.PropertyErrorf("sdk_version", `system_modules is required to be set to a non-empty value when sdk_version is "none", did you mean sdk_version: "core_platform"?`) } else if systemModules == "none" { - // Normalize no system modules to an empty string. - systemModules = "" + return sdkDep{ + noStandardLibs: true, + } } return sdkDep{ + useModule: true, noStandardLibs: true, systemModules: systemModules, + modules: []string{systemModules}, } case "core_platform": return sdkDep{ -- cgit v1.2.3-59-g8ed1b From 6cef481ee7c27ee08b9da3ace059860851cd8b69 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 17 Oct 2019 14:23:50 -0700 Subject: Use java language 1.9 for sdk_version: "current" Java language was set for 1.8 for anything building against the current SDK because the stubs were not built in Soong, so the system modules could not be built. The stubs have been built in Soong since Iabd32b30954b3f4a6d9a779fde52a032b684807e, but I5e870c34dd0ebc8ae3f888ec627da590c846a76f missed updating this TODO. Use 1.9 when building against the stubs, but continue using 1.8 for unbundled builds until we have prebuilt system modules. Always use the core-current-stubs-system-modules to avoid splitting android.* packages between the system modules and the classpath, which would cause new classes in android.* packages in classpath jars to be ignored. Add a new java9Classpath field to sdkDep that will contain the stubs jar when targeting Java language level 1.9, and plumb it through to javac and turbine. Rename the modules field to bootclasspath. Bug: 142896162 Test: m checkbuild Change-Id: Icfd32d0a863b2303a997c7cf03cb3708aade4724 --- java/builder.go | 33 ++++++++++++++++++------------ java/droiddoc.go | 13 ++++++++++-- java/java.go | 29 +++++++++++++++++---------- java/sdk.go | 18 ++++++----------- java/sdk_test.go | 61 +++++++++++++++++++++++++++++++++++++------------------- 5 files changed, 95 insertions(+), 59 deletions(-) (limited to 'java/java.go') diff --git a/java/builder.go b/java/builder.go index dce33a4c0..169d85318 100644 --- a/java/builder.go +++ b/java/builder.go @@ -182,15 +182,16 @@ func init() { } type javaBuilderFlags struct { - javacFlags string - bootClasspath classpath - classpath classpath - processorPath classpath - processor string - systemModules *systemModules - aidlFlags string - aidlDeps android.Paths - javaVersion javaVersion + javacFlags string + bootClasspath classpath + classpath classpath + java9Classpath classpath + processorPath classpath + processor string + systemModules *systemModules + aidlFlags string + aidlDeps android.Paths + javaVersion javaVersion errorProneExtraJavacFlags string errorProneProcessorPath classpath @@ -295,11 +296,14 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android. var deps android.Paths deps = append(deps, srcJars...) + classpath := flags.classpath + var bootClasspath string if flags.javaVersion.usesJavaModules() { var systemModuleDeps android.Paths bootClasspath, systemModuleDeps = flags.systemModules.FormTurbineSystemModulesPath(ctx.Device()) deps = append(deps, systemModuleDeps...) + classpath = append(flags.java9Classpath, classpath...) } else { deps = append(deps, flags.bootClasspath...) if len(flags.bootClasspath) == 0 && ctx.Device() { @@ -311,7 +315,7 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android. } } - deps = append(deps, flags.classpath...) + deps = append(deps, classpath...) deps = append(deps, flags.processorPath...) ctx.Build(pctx, android.BuildParams{ @@ -324,7 +328,7 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android. "javacFlags": flags.javacFlags, "bootClasspath": bootClasspath, "srcJars": strings.Join(srcJars.Strings(), " "), - "classpath": strings.Join(flags.classpath.FormTurbineClasspath("--classpath "), " "), + "classpath": strings.Join(classpath.FormTurbineClasspath("--classpath "), " "), "outDir": android.PathForModuleOut(ctx, "turbine", "classes").String(), "javaVersion": flags.javaVersion.String(), }, @@ -347,11 +351,14 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab deps = append(deps, srcJars...) + classpath := flags.classpath + var bootClasspath string if flags.javaVersion.usesJavaModules() { var systemModuleDeps android.Paths bootClasspath, systemModuleDeps = flags.systemModules.FormJavaSystemModulesPath(ctx.Device()) deps = append(deps, systemModuleDeps...) + classpath = append(flags.java9Classpath, classpath...) } else { deps = append(deps, flags.bootClasspath...) if len(flags.bootClasspath) == 0 && ctx.Device() { @@ -363,7 +370,7 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab } } - deps = append(deps, flags.classpath...) + deps = append(deps, classpath...) deps = append(deps, flags.processorPath...) processor := "-proc:none" @@ -389,7 +396,7 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab Args: map[string]string{ "javacFlags": flags.javacFlags, "bootClasspath": bootClasspath, - "classpath": flags.classpath.FormJavaClassPath("-classpath"), + "classpath": classpath.FormJavaClassPath("-classpath"), "processorpath": flags.processorPath.FormJavaClassPath("-processorpath"), "processor": processor, "srcJars": strings.Join(srcJars.Strings(), " "), diff --git a/java/droiddoc.go b/java/droiddoc.go index 714412c77..6f3b15246 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -429,8 +429,9 @@ func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) { ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...) } } else if sdkDep.useModule { - ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...) + ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...) ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) + ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...) } } @@ -505,7 +506,8 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps { sdkDep := decodeSdkDep(ctx, sdkContext(j)) if sdkDep.invalidVersion { - ctx.AddMissingDependencies(sdkDep.modules) + ctx.AddMissingDependencies(sdkDep.bootclasspath) + ctx.AddMissingDependencies(sdkDep.java9Classpath) } else if sdkDep.useFiles { deps.bootClasspath = append(deps.bootClasspath, sdkDep.jars...) } @@ -538,6 +540,13 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps { default: ctx.ModuleErrorf("depends on non-java module %q", otherName) } + case java9LibTag: + switch dep := module.(type) { + case Dependency: + deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars()...) + default: + ctx.ModuleErrorf("depends on non-java module %q", otherName) + } case systemModulesTag: if deps.systemModules != nil { panic("Found two system module dependencies") diff --git a/java/java.go b/java/java.go index 4fc5a6f58..947aa8caa 100644 --- a/java/java.go +++ b/java/java.go @@ -140,10 +140,10 @@ type CompilerProperties struct { Use_tools_jar *bool Openjdk9 struct { - // List of source files that should only be used when passing -source 1.9 + // List of source files that should only be used when passing -source 1.9 or higher Srcs []string `android:"path"` - // List of javac flags that should only be used when passing -source 1.9 + // List of javac flags that should only be used when passing -source 1.9 or higher Javacflags []string } @@ -433,6 +433,7 @@ type jniDependencyTag struct { var ( staticLibTag = dependencyTag{name: "staticlib"} libTag = dependencyTag{name: "javalib"} + java9LibTag = dependencyTag{name: "java9lib"} pluginTag = dependencyTag{name: "plugin"} bootClasspathTag = dependencyTag{name: "bootclasspath"} systemModulesTag = dependencyTag{name: "system modules"} @@ -461,12 +462,16 @@ type checkVendorModuleContext interface { type sdkDep struct { useModule, useFiles, useDefaultLibs, invalidVersion bool - modules []string + // The modules that will be added to the bootclasspath when targeting 1.8 or lower + bootclasspath []string // The default system modules to use. Will be an empty string if no system // modules are to be used. systemModules string + // The modules that will be added ot the classpath when targeting 1.9 or higher + java9Classpath []string + frameworkResModule string jars android.Paths @@ -531,8 +536,9 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...) } } else if sdkDep.useModule { - ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...) + ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...) ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) + ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...) if j.deviceProperties.EffectiveOptimizeEnabled() && sdkDep.hasStandardLibs() { ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...) ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...) @@ -630,6 +636,7 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt type deps struct { classpath classpath + java9Classpath classpath bootClasspath classpath processorPath classpath processorClasses []string @@ -739,7 +746,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { if ctx.Device() { sdkDep := decodeSdkDep(ctx, sdkContext(j)) if sdkDep.invalidVersion { - ctx.AddMissingDependencies(sdkDep.modules) + ctx.AddMissingDependencies(sdkDep.bootclasspath) + ctx.AddMissingDependencies(sdkDep.java9Classpath) } else if sdkDep.useFiles { // sdkDep.jar is actually equivalent to turbine header.jar. deps.classpath = append(deps.classpath, sdkDep.jars...) @@ -787,6 +795,8 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { // sdk lib names from dependencies are re-exported j.exportedSdkLibs = append(j.exportedSdkLibs, dep.ExportedSdkLibs()...) deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, dep.AidlIncludeDirs()...) + case java9LibTag: + deps.java9Classpath = append(deps.java9Classpath, dep.HeaderJars()...) case staticLibTag: deps.classpath = append(deps.classpath, dep.HeaderJars()...) deps.staticJars = append(deps.staticJars, dep.ImplementationJars()...) @@ -883,12 +893,8 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd return JAVA_VERSION_7 } else if ctx.Device() && sdk <= 29 { return JAVA_VERSION_8 - } else if ctx.Device() && - sdkContext.sdkVersion() != "" && - sdkContext.sdkVersion() != "none" && - sdkContext.sdkVersion() != "core_platform" && - sdk == android.FutureApiLevel { - // TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current" + } else if ctx.Device() && ctx.Config().UnbundledBuildUsePrebuiltSdks() { + // TODO(b/142896162): once we have prebuilt system modules we can use 1.9 for unbundled builds return JAVA_VERSION_8 } else { return JAVA_VERSION_9 @@ -981,6 +987,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB // classpath flags.bootClasspath = append(flags.bootClasspath, deps.bootClasspath...) flags.classpath = append(flags.classpath, deps.classpath...) + flags.java9Classpath = append(flags.java9Classpath, deps.java9Classpath...) flags.processorPath = append(flags.processorPath, deps.processorPath...) flags.processor = strings.Join(deps.processorClasses, ",") diff --git a/java/sdk.go b/java/sdk.go index d8584d2b0..6f0f432b3 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -122,7 +122,7 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() { return sdkDep{ invalidVersion: true, - modules: []string{fmt.Sprintf("sdk_%s_%s_android", api, v)}, + bootclasspath: []string{fmt.Sprintf("sdk_%s_%s_android", api, v)}, } } @@ -144,20 +144,14 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { } toModule := func(m, r string, aidl android.Path) sdkDep { - ret := sdkDep{ + return sdkDep{ useModule: true, - modules: []string{m, config.DefaultLambdaStubsLibrary}, - systemModules: m + "_system_modules", + bootclasspath: []string{m, config.DefaultLambdaStubsLibrary}, + systemModules: "core-current-stubs-system-modules", + java9Classpath: []string{m}, frameworkResModule: r, aidl: android.OptionalPathForPath(aidl), } - - if m == "core.current.stubs" { - ret.systemModules = "core-current-stubs-system-modules" - // core_current does not include framework classes. - ret.noFrameworksLibs = true - } - return ret } // Ensures that the specificed system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor apks) @@ -201,7 +195,7 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { useModule: true, noStandardLibs: true, systemModules: systemModules, - modules: []string{systemModules}, + bootclasspath: []string{systemModules}, } case "core_platform": return sdkDep{ diff --git a/java/sdk_test.go b/java/sdk_test.go index 647a0b971..525c89887 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -83,19 +83,21 @@ func TestClasspath(t *testing.T) { }, { - name: "current", - properties: `sdk_version: "current",`, - bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"}, - forces8: true, - aidl: "-p" + buildDir + "/framework.aidl", + name: "current", + properties: `sdk_version: "current",`, + bootclasspath: []string{"android_stubs_current", "core-lambda-stubs"}, + system: "core-current-stubs-system-modules", + java9classpath: []string{"android_stubs_current"}, + aidl: "-p" + buildDir + "/framework.aidl", }, { - name: "system_current", - properties: `sdk_version: "system_current",`, - bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"}, - forces8: true, - aidl: "-p" + buildDir + "/framework.aidl", + name: "system_current", + properties: `sdk_version: "system_current",`, + bootclasspath: []string{"android_system_stubs_current", "core-lambda-stubs"}, + system: "core-current-stubs-system-modules", + java9classpath: []string{"android_system_stubs_current"}, + aidl: "-p" + buildDir + "/framework.aidl", }, { @@ -108,18 +110,20 @@ func TestClasspath(t *testing.T) { }, { - name: "test_current", - properties: `sdk_version: "test_current",`, - bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"}, - forces8: true, - aidl: "-p" + buildDir + "/framework.aidl", + name: "test_current", + properties: `sdk_version: "test_current",`, + bootclasspath: []string{"android_test_stubs_current", "core-lambda-stubs"}, + system: "core-current-stubs-system-modules", + java9classpath: []string{"android_test_stubs_current"}, + aidl: "-p" + buildDir + "/framework.aidl", }, { - name: "core_current", - properties: `sdk_version: "core_current",`, - bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"}, - forces8: true, + name: "core_current", + properties: `sdk_version: "core_current",`, + bootclasspath: []string{"core.current.stubs", "core-lambda-stubs"}, + system: "core-current-stubs-system-modules", + java9classpath: []string{"core.current.stubs"}, }, { @@ -385,8 +389,23 @@ func TestClasspath(t *testing.T) { checkClasspath(t, ctx, true /* isJava8 */) }) - // TODO(b/142896162): Add a with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9, when that all works. + // Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9 + t.Run("REL + Java language level 9", func(t *testing.T) { + config := testConfig(nil) + config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("REL") + config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(true) + + if testcase.unbundled { + config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true) + } + if testcase.pdk { + config.TestProductVariables.Pdk = proptools.BoolPtr(true) + } + ctx := testContext(bp, nil) + run(t, ctx, config) + + checkClasspath(t, ctx, false /* isJava8 */) + }) }) } - } -- cgit v1.2.3-59-g8ed1b