Compile with javac by default

javac is replacing jack as the default compiler for platform builds.
Leave it on for unbundled builds, we don't have a solution for lambdas
in unbundled builds yet (b/62038127).

Temporarily allow products to continue to default to jack by setting
PRODUCT_COMPILE_WITH_JACK=true.

This reapplies I1c3857f64eafa445ad1b9dd94eff85bef05f4649.

Bug: 36902714
Test: m -j checkbuild
Test: https://android-build.googleplex.com/builds/view-workplan?viewType=Table&workplanId=L50600000086240009&nodeType=Trybot
Test: https://android-build.googleplex.com/builds/view-workplan?viewType=Table&workplanId=L68900000086676531&nodeType=Trybot
Test: https://android-build.googleplex.com/builds/view-workplan?viewType=Table&workplanId=L37200000086753998&nodeType=Trybot
Test: https://android-build.googleplex.com/builds/view-workplan?viewType=Table&workplanId=L74600000087054271&nodeType=Trybot
Test: sailfish-userdebug boots and basic interactions work
Test: art tests pass
Test: libcore tests pass
Change-Id: Icd1b549cd8a010758a6e5d98b39569fcd1825f60
diff --git a/core/combo/javac.mk b/core/combo/javac.mk
index 7d19279..0538c52 100644
--- a/core/combo/javac.mk
+++ b/core/combo/javac.mk
@@ -10,8 +10,17 @@
 #
 
 ifndef ANDROID_COMPILE_WITH_JACK
-# Defines if compilation with jack is enabled by default.
-ANDROID_COMPILE_WITH_JACK := true
+    # TODO(b/64113890, b/35788202): remove PRODUCT_COMPILE_WITH_JACK
+    ifdef PRODUCT_COMPILE_WITH_JACK
+        ANDROID_COMPILE_WITH_JACK := $(PRODUCT_COMPILE_WITH_JACK)
+    else
+        # TODO(b/62038127): remove TARGET_BUILD_APPS check
+        ifdef TARGET_BUILD_APPS
+            ANDROID_COMPILE_WITH_JACK := true
+        else
+            ANDROID_COMPILE_WITH_JACK := false
+        endif
+    endif
 endif
 
 common_jdk_flags := -Xmaxerrs 9999999
diff --git a/core/product.mk b/core/product.mk
index c5ddf81..62e3859 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -136,6 +136,7 @@
     PRODUCT_SYSTEM_HEADROOM \
     PRODUCT_MINIMIZE_JAVA_DEBUG_INFO \
     PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS \
+    PRODUCT_COMPILE_WITH_JACK \
 
 
 
diff --git a/core/product_config.mk b/core/product_config.mk
index 36f473f..b12425c 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -435,3 +435,7 @@
 # Whether any paths are excluded from sanitization when SANITIZE_TARGET=integer_overflow
 PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS := \
     $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS))
+
+# Temporarily force Jack back on for a product
+PRODUCT_COMPILE_WITH_JACK := \
+    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COMPILE_WITH_JACK))