summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
authorTobias Thierer <tobiast@google.com>2018-09-11 16:21:05 +0100
committerTobias Thierer <tobiast@google.com>2018-09-11 19:54:28 +0100
commit06dd04f20eaeeb4e82fa02341d1c1d90d451d7b0 (patch)
tree9256a29d49d2af4aa0c06d61f773d32fd8cbabc9 /java/java.go
parent0903f90e9aba79c70f6fe2b27d77aa06f0f66222 (diff)
Enable Java 9 language support through java_version: "1.9" alone.
Some logic in java.go was conditional on TargetOpenJDK9(), which in turn relies on a global build flag (EXPERIMENTAL_USE_OPENJDK9=true). This CL changes the logic in collectBuilderFlags() to check for javaVersion greater or equal "1.9" instead, which is true when either EXPERIMENTAL_USE_OPENJDK9=true (global) or javaVersion "1.9" (a per-build target attribute). Because the value of flags.javaVersion isn't available there, TargetOpenJDK9()-dependent logic in Module.deps() was changed to be unconditional; as far as I understand, this means that system modules deps will be built regardless of whether they're needed later in the build. This will probably slow down the build unnecessarily until the first user of these system modules appears (expected soon), but probably not by much. There is some TargetOpenJDK9() related logic remaining in droiddoc.go, but this doesn't seem to break the build of Java 9 language sources and is probably no longer needed now that metalava is used for generating the stubs (thanks to Nan!), and those do not contain any Java 9 language features. Bug: 112443425 Test: Checked that Java 9 language support works on AOSP after this CL without a need for EXPERIMENTAL_USE_OPENJDK9=true, ie. after also patching CL http://r.android.com/646840 , "make docs droid cts" completes, the device boots and Java9LanguageFeaturesTest passes. Change-Id: I393b97a7b3bb4c1c3d06580c639e94ff6cf916ff
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go24
1 files changed, 10 insertions, 14 deletions
diff --git a/java/java.go b/java/java.go
index 6c664d85b..0dd64ef99 100644
--- a/java/java.go
+++ b/java/java.go
@@ -553,16 +553,12 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
sdkDep := decodeSdkDep(ctx, sdkContext(j))
if sdkDep.useDefaultLibs {
ctx.AddVariationDependencies(nil, bootClasspathTag, config.DefaultBootclasspathLibraries...)
- if ctx.Config().TargetOpenJDK9() {
- ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
- }
+ ctx.AddVariationDependencies(nil, systemModulesTag, config.DefaultSystemModules)
if !Bool(j.properties.No_framework_libs) {
ctx.AddVariationDependencies(nil, libTag, config.DefaultLibraries...)
}
} else if sdkDep.useModule {
- if ctx.Config().TargetOpenJDK9() {
- ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
- }
+ ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.modules...)
if Bool(j.deviceProperties.Optimize.Enabled) {
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultBootclasspathLibraries...)
@@ -572,7 +568,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
} else if j.deviceProperties.System_modules == nil {
ctx.PropertyErrorf("no_standard_libs",
"system_modules is required to be set when no_standard_libs is true, did you mean no_framework_libs?")
- } else if *j.deviceProperties.System_modules != "none" && ctx.Config().TargetOpenJDK9() {
+ } else if *j.deviceProperties.System_modules != "none" {
ctx.AddVariationDependencies(nil, systemModulesTag, *j.deviceProperties.System_modules)
}
if (ctx.ModuleName() == "framework") || (ctx.ModuleName() == "framework-annotation-proc") {
@@ -900,9 +896,12 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
var flags javaBuilderFlags
+ // javaVersion flag.
+ flags.javaVersion = getJavaVersion(ctx, String(j.properties.Java_version), sdkContext(j))
+
// javac flags.
javacFlags := j.properties.Javacflags
- if ctx.Config().TargetOpenJDK9() {
+ if flags.javaVersion == "1.9" {
javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...)
}
if ctx.Config().MinimizeJavaDebugInfo() {
@@ -927,15 +926,12 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
flags.errorProneProcessorPath = classpath(android.PathsForSource(ctx, config.ErrorProneClasspath))
}
- // javaVersion flag.
- flags.javaVersion = getJavaVersion(ctx, String(j.properties.Java_version), sdkContext(j))
-
// classpath
flags.bootClasspath = append(flags.bootClasspath, deps.bootClasspath...)
flags.classpath = append(flags.classpath, deps.classpath...)
flags.processorPath = append(flags.processorPath, deps.processorPath...)
- if len(flags.bootClasspath) == 0 && ctx.Host() && !ctx.Config().TargetOpenJDK9() &&
+ if len(flags.bootClasspath) == 0 && ctx.Host() && flags.javaVersion != "1.9" &&
!Bool(j.properties.No_standard_libs) &&
inList(flags.javaVersion, []string{"1.6", "1.7", "1.8"}) {
// Give host-side tools a version of OpenJDK's standard libraries
@@ -961,7 +957,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
}
}
- if j.properties.Patch_module != nil && ctx.Config().TargetOpenJDK9() {
+ if j.properties.Patch_module != nil && flags.javaVersion == "1.9" {
patchClasspath := ".:" + flags.classpath.FormJavaClassPath("")
javacFlags = append(javacFlags, "--patch-module="+String(j.properties.Patch_module)+"="+patchClasspath)
}
@@ -995,7 +991,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
deps := j.collectDeps(ctx)
flags := j.collectBuilderFlags(ctx, deps)
- if ctx.Config().TargetOpenJDK9() {
+ if flags.javaVersion == "1.9" {
j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
}
srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)