Add errorprone functionality. Still got some module access issues. ihse-errorprone-branch
authorihse
Thu, 02 Aug 2018 09:59:12 -0700
branchihse-errorprone-branch
changeset 56846 1186bac4e290
parent 56844 16c07e1567e7
child 57056 85a97ef23187
Add errorprone functionality. Still got some module access issues.
make/common/JavaCompilation.gmk
make/common/SetupJavaCompilers.gmk
--- a/make/common/JavaCompilation.gmk	Wed Aug 01 22:43:18 2018 -0700
+++ b/make/common/JavaCompilation.gmk	Thu Aug 02 09:59:12 2018 -0700
@@ -206,6 +206,7 @@
   $1_SJAVAC_PORTFILE := $$($$($1_SETUP)_SJAVAC_PORTFILE)
   $1_SERVER_JVM := $$($$($1_SETUP)_SERVER_JVM)
   $1_DISABLE_SJAVAC := $$($$($1_SETUP)_DISABLE_SJAVAC)
+  $1_PROCESSORPATH := $$($$($1_SETUP)_PROCESSORPATH)
 
   ifneq ($$($1_MODULE), )
     $1_MODULE_SUBDIR := /$$($1_MODULE)
@@ -451,14 +452,16 @@
       endif
 
       ifeq ($$($1_CREATE_API_DIGEST), true)
-        $1_API_DIGEST_FLAGS := \
-            -classpath $(BUILDTOOLS_OUTPUTDIR)/depend \
-            -Xplugin:"depend $$($1_API_TARGET)" \
-            #
+        $1_FLAGS += -Xplugin:"depend $$($1_API_TARGET)"
+        $1_PROCESSORPATH += $(BUILDTOOLS_OUTPUTDIR)/depend
 
         $1_EXTRA_DEPS := $(BUILDTOOLS_OUTPUTDIR)/depend/_the.COMPILE_DEPEND_batch
       endif
 
+      ifneq ($$($1_PROCESSORPATH), )
+        $1_FLAGS += -processorpath $$(call PathList, $$($1_PROCESSORPATH))
+      endif
+
       # When not using sjavac, pass along all sources to javac using an @file.
       $$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_DEPENDS) $$($1_VARDEPS_FILE) \
           $$($1_EXTRA_DEPS)
@@ -468,7 +471,6 @@
 		$$(call ExecuteWithLog, $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$$($1_SAFE_NAME)_batch, \
 		    $$($1_JVM) $$($1_JAVAC_CMD) $$($1_FLAGS) \
 		        -implicit:none \
-		        $$($1_API_DIGEST_FLAGS) \
 		        -d $$($1_BIN) $$($1_HEADERS_ARG) @$$@.tmp) && \
 		$(MV) $$@.tmp $$@
     endif
--- 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)))