diff --git a/core/java.mk b/core/java.mk index 8dc4b22e9..029f99c32 100644 --- a/core/java.mk +++ b/core/java.mk @@ -425,6 +425,16 @@ ifeq ($(RUN_ERROR_PRONE),true) LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS) endif +# For user / userdebug builds, strip the local variable table and the local variable +# type table. This has no bearing on stack traces, but will leave less information +# available via JDWP. +ifneq (,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO)) +ifneq (,$(filter userdebug user,$(TARGET_BUILD_VARIANT))) +LOCAL_JAVACFLAGS+= -g:source,lines +LOCAL_JACK_FLAGS+= -D jack.dex.debug.vars=false -D jack.dex.debug.vars.synthetic=false +endif +endif + $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES) $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES) diff --git a/core/product.mk b/core/product.mk index 34cd21ca6..6e9371687 100644 --- a/core/product.mk +++ b/core/product.mk @@ -133,6 +133,7 @@ _product_var_list := \ PRODUCT_ART_USE_READ_BARRIER \ PRODUCT_IOT \ PRODUCT_SYSTEM_HEADROOM \ + PRODUCT_MINIMIZE_JAVA_DEBUG_INFO \ diff --git a/core/product_config.mk b/core/product_config.mk index 2b2d7b369..5bd4ac638 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -423,3 +423,7 @@ PRODUCT_ENFORCE_RRO_TARGETS := \ # Add reserved headroom to a system image. PRODUCT_SYSTEM_HEADROOM := \ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_HEADROOM)) + +# Whether to save disk space by minimizing java debug info +PRODUCT_MINIMIZE_JAVA_DEBUG_INFO := \ + $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MINIMIZE_JAVA_DEBUG_INFO))