Merge "Normalize and validate the java_version property."

This commit is contained in:
Treehugger Robot 2019-08-29 18:15:07 +00:00 committed by Gerrit Code Review
commit 17f4728d4b
1 changed files with 20 additions and 1 deletions

View File

@ -907,7 +907,7 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd
ctx.PropertyErrorf("sdk_version", "%s", err)
}
if javaVersion != "" {
ret = javaVersion
ret = normalizeJavaVersion(ctx, javaVersion)
} else if ctx.Device() && sdk <= 23 {
ret = "1.7"
} else if ctx.Device() && sdk <= 29 || !ctx.Config().TargetOpenJDK9() {
@ -926,6 +926,25 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext sd
return ret
}
func normalizeJavaVersion(ctx android.ModuleContext, javaVersion string) string {
switch javaVersion {
case "1.6", "6":
return "1.6"
case "1.7", "7":
return "1.7"
case "1.8", "8":
return "1.8"
case "1.9", "9":
return "1.9"
case "10", "11":
ctx.PropertyErrorf("java_version", "Java language levels above 9 are not supported")
return "unsupported"
default:
ctx.PropertyErrorf("java_version", "Unrecognized Java language level")
return "unrecognized"
}
}
func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaBuilderFlags {
var flags javaBuilderFlags