--- a/make/common/SetupJavaCompilers.gmk Wed Aug 01 22:43:18 2018 -0700
+++ b/make/common/SetupJavaCompilers.gmk Thu Aug 02 09:59:12 2018 -0700
@@ -67,13 +67,37 @@
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
+ifneq ($(ERRORPRONE_JAR), )
+ # Extra flags needed to run bootstrap javac with the errorprone static code
+ # analysis tool as -Xplugin.
+
+ ERRORPRONE_JAVA_FLAGS := \
+ --add-exports jdk.compiler.interim/com.sun.tools.javac.api=ALL-UNNAMED \
+ --add-exports jdk.compiler.interim/com.sun.tools.javac.util=ALL-UNNAMED \
+ --add-exports jdk.compiler.interim/com.sun.tools.javac.tree=ALL-UNNAMED \
+ --add-exports jdk.compiler.interim/com.sun.tools.javac.main=ALL-UNNAMED \
+ --add-exports jdk.compiler.interim/com.sun.tools.javac.code=ALL-UNNAMED \
+ --add-exports jdk.compiler.interim/com.sun.tools.javac.processing=ALL-UNNAMED \
+ --add-exports jdk.compiler.interim/com.sun.tools.javac.parser=ALL-UNNAMED \
+ --add-exports jdk.compiler.interim/com.sun.tools.javac.comp=ALL-UNNAMED \
+ --add-opens=jdk.compiler.interim/com.sun.tools.javac.comp=ALL-UNNAMED \
+ #
+
+ ERRORPRONE_JAVAC_FLAGS := \
+ '-Xplugin:ErrorProne -XepDisableAllChecks -Xep:CollectionIncompatibleType:ERROR' \
+ -XDcompilePolicy=byfile \
+ #
+endif
+
# The generate new bytecode javac setup uses the new compiler to compile for the
# new jdk. This new bytecode might only be possible to run using the new jvm.
$(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
- JVM := $(JAVA_JAVAC), \
+ JVM := $(JAVA_JAVAC) $(ERRORPRONE_JAVA_FLAGS), \
JAVAC := $(NEW_JAVAC), \
FLAGS := -source 12 -target 12 --doclint-format html5 \
- -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \
+ -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS) \
+ $(ERRORPRONE_JAVAC_FLAGS), \
+ PROCESSORPATH := $(ERRORPRONE_JAR), \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))