Initial support for converting jars to java9 system modules

Adds a java_system_modules module type that (when
EXPERIMENTAL_USE_OPENJDK9 is set to true) converts a list of
java library modules and prebuilt jars into system modules,
and plumbs the system modules through to the javac command
line.

Also exports the location of the system modules to make
variables, as well as the name of the default system module.

Test: TestClasspath in java_test.go, runs automatically as part of the build
Bug: 63986449
Change-Id: I27bd5d2010092422a27b69c91568e49010e02f40
This commit is contained in:
Colin Cross
2017-09-29 17:58:17 -07:00
parent 070879e69e
commit 1369cdb280
9 changed files with 421 additions and 69 deletions

View File

@@ -27,6 +27,7 @@ var (
pctx = android.NewPackageContext("android/soong/java/config")
DefaultBootclasspathLibraries = []string{"core-oj", "core-libart"}
DefaultSystemModules = "core-system-modules"
DefaultLibraries = []string{"ext", "framework", "okhttp"}
)
@@ -47,9 +48,10 @@ func init() {
// If a different javac is used the flag will be ignored and extra bridges will be inserted.
// The flag is implemented by https://android-review.googlesource.com/c/486427
`-XDskipDuplicateBridges=true`,
}, " "))
pctx.StaticVariable("DefaultJavaVersion", "1.8")
// b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9
`-XDstringConcat=inline`,
}, " "))
pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS)
@@ -57,7 +59,7 @@ func init() {
if override := config.(android.Config).Getenv("OVERRIDE_ANDROID_JAVA_HOME"); override != "" {
return override, nil
}
if jdk9 := config.(android.Config).Getenv("EXPERIMENTAL_USE_OPENJDK9"); jdk9 != "" {
if config.(android.Config).UseOpenJDK9() {
return "prebuilts/jdk/jdk9/${hostPrebuiltTag}", nil
}
return "prebuilts/jdk/jdk8/${hostPrebuiltTag}", nil
@@ -71,6 +73,7 @@ func init() {
pctx.SourcePathVariable("JavadocCmd", "${JavaToolchain}/javadoc")
pctx.SourcePathVariable("JlinkCmd", "${JavaToolchain}/jlink")
pctx.SourcePathVariable("JmodCmd", "${JavaToolchain}/jmod")
pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar")
pctx.SourcePathVariable("JarArgsCmd", "build/soong/scripts/jar-args.sh")
pctx.StaticVariable("SoongZipCmd", filepath.Join("${bootstrap.ToolDir}", "soong_zip"))
@@ -86,17 +89,3 @@ func init() {
return "", nil
})
}
func StripJavac9Flags(flags []string) []string {
var ret []string
for _, f := range flags {
switch {
case strings.HasPrefix(f, "-J--add-modules="):
// drop
default:
ret = append(ret, f)
}
}
return ret
}