From 91ba6c7e01e03bde6e2f24b6d093603391149ae7 Mon Sep 17 00:00:00 2001 From: Julien Desprez Date: Tue, 14 Feb 2023 20:26:31 +0000 Subject: [PATCH] Revert "Reland "Target Java 17"" This reverts commit 1fbf7f21a452d372c629e6736ee17a216c23a926. Reason for revert: broke docker image, pinning is incomplete it seems Change-Id: I7102cb233a4fe5ce0f5a1ead98cfc661c3d82ce5 --- android/config.go | 4 ++++ java/java.go | 8 +++++++- java/sdk.go | 10 +++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/android/config.go b/android/config.go index 255c836bf..d5ed883fa 100644 --- a/android/config.go +++ b/android/config.go @@ -723,6 +723,10 @@ func (c *config) IsEnvFalse(key string) bool { return value == "0" || value == "n" || value == "no" || value == "off" || value == "false" } +func (c *config) TargetsJava17() bool { + return c.IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_17") +} + // EnvDeps returns the environment variables this build depends on. The first // call to this function blocks future reads from the environment. func (c *config) EnvDeps() map[string]string { diff --git a/java/java.go b/java/java.go index 6e428cb1f..3b0ad8d9f 100644 --- a/java/java.go +++ b/java/java.go @@ -510,8 +510,14 @@ func getJavaVersion(ctx android.ModuleContext, javaVersion string, sdkContext an return normalizeJavaVersion(ctx, javaVersion) } else if ctx.Device() { return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx)) - } else { + } else if ctx.Config().TargetsJava17() { + // Temporary experimental flag to be able to try and build with + // java version 17 options. The flag, if used, just sets Java + // 17 as the default version, leaving any components that + // target an older version intact. return JAVA_VERSION_17 + } else { + return JAVA_VERSION_11 } } diff --git a/java/sdk.go b/java/sdk.go index 10ae3f6e8..b0da5afba 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -57,10 +57,14 @@ func defaultJavaLanguageVersion(ctx android.EarlyModuleContext, s android.SdkSpe return JAVA_VERSION_8 } else if sdk.FinalOrFutureInt() <= 31 { return JAVA_VERSION_9 - } else if sdk.FinalOrFutureInt() <= 32 { - return JAVA_VERSION_11 - } else { + } else if ctx.Config().TargetsJava17() { + // Temporary experimental flag to be able to try and build with + // java version 17 options. The flag, if used, just sets Java + // 17 as the default version, leaving any components that + // target an older version intact. return JAVA_VERSION_17 + } else { + return JAVA_VERSION_11 } }