Merge "Implicitly bump up Java target to 1.8" into main

This commit is contained in:
Treehugger Robot
2024-01-16 18:09:41 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 9 deletions

View File

@@ -564,9 +564,11 @@ const (
func (v javaVersion) String() string { func (v javaVersion) String() string {
switch v { switch v {
case JAVA_VERSION_6: case JAVA_VERSION_6:
return "1.6" // Java version 1.6 no longer supported, bumping to 1.8
return "1.8"
case JAVA_VERSION_7: case JAVA_VERSION_7:
return "1.7" // Java version 1.7 no longer supported, bumping to 1.8
return "1.8"
case JAVA_VERSION_8: case JAVA_VERSION_8:
return "1.8" return "1.8"
case JAVA_VERSION_9: case JAVA_VERSION_9:
@@ -583,10 +585,12 @@ func (v javaVersion) String() string {
func (v javaVersion) StringForKotlinc() string { func (v javaVersion) StringForKotlinc() string {
// $ ./external/kotlinc/bin/kotlinc -jvm-target foo // $ ./external/kotlinc/bin/kotlinc -jvm-target foo
// error: unknown JVM target version: foo // error: unknown JVM target version: foo
// Supported versions: 1.6, 1.8, 9, 10, 11, 12, 13, 14, 15, 16, 17 // Supported versions: 1.8, 9, 10, 11, 12, 13, 14, 15, 16, 17
switch v { switch v {
case JAVA_VERSION_6:
return "1.8"
case JAVA_VERSION_7: case JAVA_VERSION_7:
return "1.6" return "1.8"
case JAVA_VERSION_9: case JAVA_VERSION_9:
return "9" return "9"
default: default:
@@ -602,9 +606,11 @@ func (v javaVersion) usesJavaModules() bool {
func normalizeJavaVersion(ctx android.BaseModuleContext, javaVersion string) javaVersion { func normalizeJavaVersion(ctx android.BaseModuleContext, javaVersion string) javaVersion {
switch javaVersion { switch javaVersion {
case "1.6", "6": case "1.6", "6":
return JAVA_VERSION_6 // Java version 1.6 no longer supported, bumping to 1.8
return JAVA_VERSION_8
case "1.7", "7": case "1.7", "7":
return JAVA_VERSION_7 // Java version 1.7 no longer supported, bumping to 1.8
return JAVA_VERSION_8
case "1.8", "8": case "1.8", "8":
return JAVA_VERSION_8 return JAVA_VERSION_8
case "1.9", "9": case "1.9", "9":

View File

@@ -47,9 +47,7 @@ func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpe
if err != nil { if err != nil {
ctx.PropertyErrorf("sdk_version", "%s", err) ctx.PropertyErrorf("sdk_version", "%s", err)
} }
if sdk.FinalOrFutureInt() <= 23 { if sdk.FinalOrFutureInt() <= 29 {
return JAVA_VERSION_7
} else if sdk.FinalOrFutureInt() <= 29 {
return JAVA_VERSION_8 return JAVA_VERSION_8
} else if sdk.FinalOrFutureInt() <= 31 { } else if sdk.FinalOrFutureInt() <= 31 {
return JAVA_VERSION_9 return JAVA_VERSION_9