From 98caed6e7fa2a3b26299d0b0005838900c63d064 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 25 Oct 2017 17:33:38 -0700 Subject: [PATCH] Fix desugaring when LOCAL_SDK_VERSION is not set When LOCAL_SDK_VERSION is not set, frameworks.jar is put in the classpath for javac. If it is also in the classpath (as opposed to the bootclasspath) for desugar then desugar tries to rewrite classes that implement interfaces with default methods to contain calls to the generated companion classes for those interfaces. frameworks.jar will not contain the companion classes, which causes proguard to fail. Move frameworks.jar to the bootclasspath, which matches more closely with builds against the SDK stubs jars. Also remove the static libraries from the classpath, they have already been merged into the input jar. Test: m checkbuild Change-Id: If30943efcaea44b2db1b38a6c1d558113324757f --- core/definitions.mk | 2 +- core/host_dalvik_java_library.mk | 4 ---- core/java.mk | 19 ------------------- core/java_common.mk | 30 ++++++++++++++++++++---------- 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/core/definitions.mk b/core/definitions.mk index d0009ee9e8..e5dbdbc961 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2397,7 +2397,7 @@ $(hide) $(JAVA) \ -Djdk.internal.lambda.dumpProxyClasses=$(abspath $(dir $@))/desugar_dumped_classes \ -jar $(DESUGAR) \ $(addprefix --bootclasspath_entry ,$(PRIVATE_BOOTCLASSPATH)) \ - $(addprefix --classpath_entry ,$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES)) \ + $(addprefix --classpath_entry ,$(PRIVATE_SHARED_JAVA_HEADER_LIBRARIES)) \ --min_sdk_version $(call codename-or-sdk-to-sdk,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ --desugar_try_with_resources_if_needed=false \ --allow_empty_bootclasspath \ diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk index 4bfe288487..a522f0bb82 100644 --- a/core/host_dalvik_java_library.mk +++ b/core/host_dalvik_java_library.mk @@ -28,10 +28,6 @@ USE_CORE_LIB_BOOTCLASSPATH := true include $(BUILD_SYSTEM)/host_java_library_common.mk ####################################### -ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) - LOCAL_JAVA_LIBRARIES := core-oj-hostdex core-libart-hostdex $(LOCAL_JAVA_LIBRARIES) -endif - full_classes_turbine_jar := $(intermediates.COMMON)/classes-turbine.jar full_classes_header_jarjar := $(intermediates.COMMON)/classes-header-jarjar.jar full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar diff --git a/core/java.mk b/core/java.mk index c02895ec64..27d352922e 100644 --- a/core/java.mk +++ b/core/java.mk @@ -18,25 +18,6 @@ endif #PDK LOCAL_NO_STANDARD_LIBRARIES:=$(strip $(LOCAL_NO_STANDARD_LIBRARIES)) LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION)) -ifneq ($(LOCAL_MODULE),jacocoagent) - ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) - ifeq ($(EMMA_INSTRUMENT),true) - ifneq ($(EMMA_INSTRUMENT_STATIC),true) - # For instrumented build, if Jacoco is not being included statically - # in instrumented packages then include Jacoco classes into the - # bootclasspath. - LOCAL_JAVA_LIBRARIES := jacocoagent $(LOCAL_JAVA_LIBRARIES) - endif # EMMA_INSTRUMENT_STATIC - endif # EMMA_INSTRUMENT - endif # !LOCAL_NO_STANDARD_LIBRARIES -endif # LOCAL_MODULE == jacocoagent - -ifndef LOCAL_SDK_VERSION - ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) - LOCAL_JAVA_LIBRARIES := $(TARGET_DEFAULT_JAVA_LIBRARIES) $(LOCAL_JAVA_LIBRARIES) - endif -endif - proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES)) ifneq ($(proto_sources),) ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro) diff --git a/core/java_common.mk b/core/java_common.mk index a73c6dbb88..15f7c1b14d 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -200,8 +200,6 @@ full_java_bootclasspath_libs := empty_bootclasspath := my_system_modules := -# full_java_libs: The list of files that should be used as the classpath. -# Using this list as a dependency list WILL NOT WORK. ifndef LOCAL_IS_HOST_MODULE ifeq ($(LOCAL_SDK_VERSION),) ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) @@ -212,8 +210,19 @@ ifndef LOCAL_IS_HOST_MODULE # now, so just always assume that they want the default system modules my_system_modules := $(DEFAULT_SYSTEM_MODULES) else # LOCAL_NO_STANDARD_LIBRARIES - full_java_bootclasspath_libs := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES)) + full_java_bootclasspath_libs := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES)) + LOCAL_JAVA_LIBRARIES := $(filter-out $(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES),$(LOCAL_JAVA_LIBRARIES)) my_system_modules := $(DEFAULT_SYSTEM_MODULES) + ifneq ($(LOCAL_MODULE),jacocoagent) + ifeq ($(EMMA_INSTRUMENT),true) + ifneq ($(EMMA_INSTRUMENT_STATIC),true) + # For instrumented build, if Jacoco is not being included statically + # in instrumented packages then include Jacoco classes into the + # bootclasspath. + full_java_bootclasspath_libs += $(call java-lib-header-files,jacocoagent) + endif # EMMA_INSTRUMENT_STATIC + endif # EMMA_INSTRUMENT + endif # LOCAL_MODULE == jacocoagent endif # LOCAL_NO_STANDARD_LIBRARIES else ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) @@ -265,6 +274,7 @@ else # LOCAL_IS_HOST_MODULE full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\ $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES))) + full_shared_java_header_libs := $(full_shared_java_libs) endif # USE_CORE_LIB_BOOTCLASSPATH endif # !LOCAL_IS_HOST_MODULE @@ -294,9 +304,6 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := $(full_java_bootclasspat $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EMPTY_BOOTCLASSPATH := $(empty_bootclasspath) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SYSTEM_MODULES := $(my_system_modules_dir) -full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH) -full_java_header_libs := $(full_shared_java_header_libs) $(full_static_java_header_libs) - ifndef LOCAL_IS_HOST_MODULE # This is set by packages that are linking to other packages that export # shared libraries, allowing them to make use of the code in the linked apk. @@ -307,8 +314,7 @@ ifneq ($(apk_libraries),) # link against the jar with full original names (before proguard processing). full_shared_java_libs += $(link_apk_libraries) - full_java_libs += $(link_apk_libraries) - full_java_header_libs += $(link_apk_header_libs) + full_shared_java_header_libs += $(link_apk_header_libs) endif # This is set by packages that contain instrumentation, allowing them to @@ -330,8 +336,8 @@ ifdef LOCAL_INSTRUMENTATION_FOR else link_instr_classes_header_jar := $(link_instr_intermediates_dir.COMMON)/classes.jar endif - full_java_libs += $(link_instr_classes_jar) - full_java_header_libs += $(link_instr_classes_header_jar) + full_shared_java_libs += $(link_instr_classes_jar) + full_shared_java_header_libs += $(link_instr_classes_header_jar) endif # LOCAL_INSTRUMENTATION_FOR endif # LOCAL_IS_HOST_MODULE @@ -378,8 +384,12 @@ ALL_MODULES.$(my_register_name).RS_FILES := $(renderscript_sources_fullpath) endif endif # !LOCAL_IS_HOST_MODULE +full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH) +full_java_header_libs := $(full_shared_java_header_libs) $(full_static_java_header_libs) + $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JAVA_LIBRARIES := $(full_java_libs) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SHARED_JAVA_HEADER_LIBRARIES := $(full_shared_java_header_libs) ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \ $(ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)