From 0276db1ec7ffef5f1a52a9884920abbd126c6a91 Mon Sep 17 00:00:00 2001 From: Tobias Thierer Date: Wed, 1 Nov 2017 16:53:09 +0000 Subject: [PATCH] javac 9 -target 1.9: Move bootclasspath jars onto classpath. When building with OpenJDK 9's javac with -source 1.9 -target 1.9, a runtime image (with system modules) is used via the --system command line flag, instead of --bootclasspath. The runtime image only contains the default libraries (libcore) but is missing other libraries that might be on the bootclasspath for a particular build target. This CL fixes compilation for this case by adding the missing jars onto the classpath instead. This already used to work but was broken by CL [1]. I attempted to conditionally revert some of that CL's changes to java_common.mk for the case of language level 1.9, but couldn't get it to work. Therefore this CL follows a different approach. [1] http://r.android.com/519552 Bug: 38177569 Test: Treehugger Test: Ran "EXPERIMENTAL_USE_OPENJDK9=true make checkbuild docs" and spot-checked some javac invocations to confirm that the system modules libs were not included in the bootclasspath, but other libs were. Change-Id: I48fd11aac9b310bfa58dee0f9cfb3ef33f10bca8 --- core/definitions.mk | 8 +++++--- core/java_common.mk | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/definitions.mk b/core/definitions.mk index 64882d91c..68182f753 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2241,15 +2241,17 @@ $(hide) if [ -s $(PRIVATE_JAVA_SOURCE_LIST) ] ; then \ $(SOONG_JAVAC_WRAPPER) $(JAVAC_WRAPPER) $(1) -encoding UTF-8 \ $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \ $(if $(PRIVATE_USE_SYSTEM_MODULES), \ - $(addprefix --system=,$(PRIVATE_SYSTEM_MODULES)), \ + $(addprefix --system=,$(PRIVATE_SYSTEM_MODULES_DIR)), \ $(addprefix -bootclasspath ,$(strip \ $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH)) \ $(PRIVATE_EMPTY_BOOTCLASSPATH)))) \ $(if $(PRIVATE_USE_SYSTEM_MODULES), \ $(if $(PRIVATE_PATCH_MODULE), \ --patch-module=$(PRIVATE_PATCH_MODULE)=$(call normalize-path-list,. $(2)))) \ - $(addprefix -classpath ,$(strip \ - $(call normalize-path-list,$(2)))) \ + $(addprefix -classpath ,$(call normalize-path-list,$(strip \ + $(if $(PRIVATE_USE_SYSTEM_MODULES), \ + $(filter-out $(PRIVATE_SYSTEM_MODULES_LIBS),$(PRIVATE_BOOTCLASSPATH))) \ + $(2)))) \ $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \ -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) -s $(PRIVATE_ANNO_INTERMEDIATES_DIR) \ $(PRIVATE_JAVACFLAGS) \ diff --git a/core/java_common.mk b/core/java_common.mk index 436f3a3b3..ac8b0d2dd 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -358,7 +358,9 @@ endif $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := $(full_java_bootclasspath_libs) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EMPTY_BOOTCLASSPATH := $(empty_bootclasspath) -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SYSTEM_MODULES := $(my_system_modules_dir) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SYSTEM_MODULES := $(my_system_modules) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SYSTEM_MODULES_DIR := $(my_system_modules_dir) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SYSTEM_MODULES_LIBS := $(call java-lib-files,$(SOONG_SYSTEM_MODULES_LIBS_$(my_system_modules))) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PATCH_MODULE := $(LOCAL_PATCH_MODULE) ifndef LOCAL_IS_HOST_MODULE