Run ErrorProne in OpenJDK9

Use the OpenJDK9 javac to run ErrorProne by adding it to
-processorpath and using -Xplugin:ErrorProne.

Bug: 69485063
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I0496006b71b70766ef16d57753cbcf037897799c
This commit is contained in:
Colin Cross
2018-06-19 22:47:35 -07:00
parent 6a77c9871c
commit 6654810f37
6 changed files with 61 additions and 78 deletions

View File

@@ -14,39 +14,40 @@
package config
import "android/soong/android"
import (
"strings"
"android/soong/android"
)
var (
// These will be filled out by external/error_prone/soong/error_prone.go if it is available
ErrorProneJavacJar string
ErrorProneJar string
ErrorProneClasspath string
ErrorProneChecksError string
ErrorProneChecksWarning string
ErrorProneChecksDefaultDisabled string
ErrorProneFlags string
ErrorProneClasspath []string
ErrorProneChecksError []string
ErrorProneChecksWarning []string
ErrorProneChecksDefaultDisabled []string
ErrorProneChecksOff []string
ErrorProneFlags []string
)
// Wrapper that grabs value of val late so it can be initialized by a later module's init function
func errorProneVar(name string, val *string) {
func errorProneVar(name string, val *[]string, sep string) {
pctx.VariableFunc(name, func(android.PackageVarContext) string {
return *val
return strings.Join(*val, sep)
})
}
func init() {
errorProneVar("ErrorProneJar", &ErrorProneJar)
errorProneVar("ErrorProneJavacJar", &ErrorProneJavacJar)
errorProneVar("ErrorProneClasspath", &ErrorProneClasspath)
errorProneVar("ErrorProneChecksError", &ErrorProneChecksError)
errorProneVar("ErrorProneChecksWarning", &ErrorProneChecksWarning)
errorProneVar("ErrorProneChecksDefaultDisabled", &ErrorProneChecksDefaultDisabled)
errorProneVar("ErrorProneFlags", &ErrorProneFlags)
pctx.StaticVariable("ErrorProneCmd",
"${JavaCmd} -Xmx${JavacHeapSize} -Xbootclasspath/p:${ErrorProneJavacJar} "+
"-cp ${ErrorProneJar}:${ErrorProneClasspath} "+
"${ErrorProneFlags} ${CommonJdkFlags} "+
"${ErrorProneChecksError} ${ErrorProneChecksWarning} ${ErrorProneChecksDefaultDisabled}")
errorProneVar("ErrorProneClasspath", &ErrorProneClasspath, ":")
errorProneVar("ErrorProneChecksError", &ErrorProneChecksError, " ")
errorProneVar("ErrorProneChecksWarning", &ErrorProneChecksWarning, " ")
errorProneVar("ErrorProneChecksDefaultDisabled", &ErrorProneChecksDefaultDisabled, " ")
errorProneVar("ErrorProneChecksOff", &ErrorProneChecksOff, " ")
errorProneVar("ErrorProneFlags", &ErrorProneFlags, " ")
pctx.StaticVariable("ErrorProneChecks", strings.Join([]string{
"${ErrorProneChecksOff}",
"${ErrorProneChecksError}",
"${ErrorProneChecksWarning}",
"${ErrorProneChecksDefaultDisabled}",
}, " "))
}

View File

@@ -52,14 +52,15 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("TURBINE", "${TurbineJar}")
if ctx.Config().IsEnvTrue("RUN_ERROR_PRONE") {
ctx.Strict("TARGET_JAVAC", "${ErrorProneCmd}")
ctx.Strict("HOST_JAVAC", "${ErrorProneCmd}")
} else {
ctx.Strict("TARGET_JAVAC", "${JavacCmd} ${CommonJdkFlags}")
ctx.Strict("HOST_JAVAC", "${JavacCmd} ${CommonJdkFlags}")
if ctx.Config().RunErrorProne() {
ctx.Strict("ERROR_PRONE_JARS", strings.Join(ErrorProneClasspath, " "))
ctx.Strict("ERROR_PRONE_FLAGS", "${ErrorProneFlags}")
ctx.Strict("ERROR_PRONE_CHECKS", "${ErrorProneChecks}")
}
ctx.Strict("TARGET_JAVAC", "${JavacCmd} ${CommonJdkFlags}")
ctx.Strict("HOST_JAVAC", "${JavacCmd} ${CommonJdkFlags}")
if ctx.Config().UseOpenJDK9() {
ctx.Strict("JLINK", "${JlinkCmd}")
ctx.Strict("JMOD", "${JmodCmd}")