From 82df516665d164220aaa1d8a867cd5fa087ffb99 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 12 Sep 2023 17:56:15 -0700 Subject: [PATCH] Update LOCAL_JAVA_LANGUAGE_VERSION logic to match Soong Support LOCAL_JAVA_LANGUAGE_VERSION := 11 or 17 and match the default value of 17 used in Soong. Bug: 298613711 Bug: 299937334 Test: m javac-check Change-Id: I19aa24cc5197ab0e6cb03361124c36ce3e316810 --- core/config.mk | 8 ++++++-- core/java_common.mk | 12 ++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/config.mk b/core/config.mk index 8ff85cf6ca..c33959022d 100644 --- a/core/config.mk +++ b/core/config.mk @@ -1224,8 +1224,12 @@ TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst %/test,test_%,$(TARGET_AVAILABLE_SDK TARGET_AVAILABLE_SDK_VERSIONS := $(filter-out %/module-lib %/system-server,$(TARGET_AVAILABLE_SDK_VERSIONS)) TARGET_AVAIALBLE_SDK_VERSIONS := $(call numerically_sort,$(TARGET_AVAILABLE_SDK_VERSIONS)) -TARGET_SDK_VERSIONS_WITHOUT_JAVA_18_SUPPORT := $(call numbers_less_than,24,$(TARGET_AVAILABLE_SDK_VERSIONS)) -TARGET_SDK_VERSIONS_WITHOUT_JAVA_19_SUPPORT := $(call numbers_less_than,30,$(TARGET_AVAILABLE_SDK_VERSIONS)) +TARGET_SDK_VERSIONS_WITHOUT_JAVA_1_8_SUPPORT := $(call numbers_less_than,24,$(TARGET_AVAILABLE_SDK_VERSIONS)) +TARGET_SDK_VERSIONS_WITHOUT_JAVA_1_9_SUPPORT := $(call numbers_less_than,30,$(TARGET_AVAILABLE_SDK_VERSIONS)) +TARGET_SDK_VERSIONS_WITHOUT_JAVA_11_SUPPORT := $(call numbers_less_than,32,$(TARGET_AVAILABLE_SDK_VERSIONS)) +TARGET_SDK_VERSIONS_WITHOUT_JAVA_17_SUPPORT := $(call numbers_less_than,34,$(TARGET_AVAILABLE_SDK_VERSIONS)) + +JAVA_LANGUAGE_VERSIONS_WITHOUT_SYSTEM_MODULES := 1.7 1.8 # This is the standard way to name a directory containing prebuilt target # objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so diff --git a/core/java_common.mk b/core/java_common.mk index 0e03d0b7b5..a5ed057993 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -25,15 +25,19 @@ ifeq (,$(LOCAL_JAVA_LANGUAGE_VERSION)) # Host modules always default to 1.9 LOCAL_JAVA_LANGUAGE_VERSION := 1.9 else - ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_18_SUPPORT))) + ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_1_8_SUPPORT))) LOCAL_JAVA_LANGUAGE_VERSION := 1.7 - else ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_19_SUPPORT))) + else ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_1_9_SUPPORT))) LOCAL_JAVA_LANGUAGE_VERSION := 1.8 + else ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_11_SUPPORT))) + LOCAL_JAVA_LANGUAGE_VERSION := 1.9 + else ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_17_SUPPORT))) + LOCAL_JAVA_LANGUAGE_VERSION := 11 else ifneq (,$(LOCAL_SDK_VERSION)$(TARGET_BUILD_USE_PREBUILT_SDKS)) # TODO(ccross): allow 1.9 for current and unbundled once we have SDK system modules LOCAL_JAVA_LANGUAGE_VERSION := 1.8 else - LOCAL_JAVA_LANGUAGE_VERSION := 1.9 + LOCAL_JAVA_LANGUAGE_VERSION := 17 endif endif endif @@ -410,7 +414,7 @@ endif full_java_system_modules_deps := my_system_modules_dir := $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_USE_SYSTEM_MODULES := -ifeq ($(LOCAL_JAVA_LANGUAGE_VERSION),1.9) +ifeq (,$(filter $(LOCAL_JAVA_LANGUAGE_VERSION),$(JAVA_LANGUAGE_VERSIONS_WITHOUT_SYSTEM_MODULES))) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_USE_SYSTEM_MODULES := true ifdef my_system_modules ifneq ($(my_system_modules),none)