From 1369cdb28013ece5eecf51dc9facc822ea9222b3 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 29 Sep 2017 17:58:17 -0700 Subject: 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 --- java/config/config.go | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'java/config/config.go') diff --git a/java/config/config.go b/java/config/config.go index 70b8fe52..7d1fa29b 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -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 -} -- cgit v1.2.3