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