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
diff --git a/android/config.go b/android/config.go
index 5abda26..dca998f 100644
--- a/android/config.go
+++ b/android/config.go
@@ -88,6 +88,9 @@
captureBuild bool // true for tests, saves build parameters for each module
ignoreEnvironment bool // true for tests, returns empty from all Getenv calls
+ useOpenJDK9 bool // Use OpenJDK9, but possibly target 1.8
+ targetOpenJDK9 bool // Use OpenJDK9 and target 1.9
+
OncePer
}
@@ -183,6 +186,10 @@
config: config,
}
+ if err := config.fromEnv(); err != nil {
+ panic(err)
+ }
+
return Config{config}
}
@@ -273,9 +280,31 @@
config.Targets = targets
config.BuildOsVariant = targets[Host][0].String()
+ if err := config.fromEnv(); err != nil {
+ return Config{}, err
+ }
+
return Config{config}, nil
}
+func (c *config) fromEnv() error {
+ switch c.Getenv("EXPERIMENTAL_USE_OPENJDK9") {
+ case "":
+ // Use OpenJDK8
+ case "1.8":
+ // Use OpenJDK9, but target 1.8
+ c.useOpenJDK9 = true
+ case "true":
+ // Use OpenJDK9 and target 1.9
+ c.useOpenJDK9 = true
+ c.targetOpenJDK9 = true
+ default:
+ return fmt.Errorf(`Invalid value for EXPERIMENTAL_USE_OPENJDK9, should be "", "1.8", or "true"`)
+ }
+
+ return nil
+}
+
func (c *config) RemoveAbandonedFiles() bool {
return false
}
@@ -518,6 +547,16 @@
return Bool(c.ProductVariables.UseGoma)
}
+// Returns true if OpenJDK9 prebuilts are being used
+func (c *config) UseOpenJDK9() bool {
+ return c.useOpenJDK9
+}
+
+// Returns true if -source 1.9 -target 1.9 is being passed to javac
+func (c *config) TargetOpenJDK9() bool {
+ return c.targetOpenJDK9
+}
+
func (c *config) ClangTidy() bool {
return Bool(c.ProductVariables.ClangTidy)
}