Enable Java language level 9 by default.

This changes the default Java language level from 8 to 9, i.e. javac
invocations now use -source 1.9 -target 1.9.

The environment variable EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9=false is
added to switch back to the language level 8 behaviour. (Previously,
setting that variable to true was required to opt in to language level
9.)

Test: make droid java tests cts docs
Test: javap -v <some class file in output> | grep 'major version' (reports 53, for classes from 'benchmarks' which is in Android.bp and 'ahat' which is in Android.mk)
Test: make RunBluetoothRoboTests RunCarSettingsLibRoboTests (two main flavours of robolectric)
Test: make cts && cts-tradefed help
Test: atest CtsLibcoreTestCases (reasonably low-level device tests)
Test: atest CtsHostTzDataTests (arbitrary host test)
Bug: 115604102
Change-Id: I9de888e1df021244d5e61c40934178676f09ecc7
Merged-In: I52be1817fa7121fca3bce3d8857cb9ed0825570c
This commit is contained in:
Pete Gillin
2019-10-01 13:57:31 +01:00
parent 300a084db6
commit 1b3370f5d7
3 changed files with 18 additions and 16 deletions

View File

@@ -386,13 +386,14 @@ func NewConfig(srcDir, buildDir string) (Config, error) {
func (c *config) fromEnv() error {
switch c.Getenv("EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9") {
case "":
// Nothing, this is the default
case "true":
// Use -source 9 -target 9
case "", "true":
// Use -source 9 -target 9. This is the default.
c.targetOpenJDK9 = true
case "false":
// Use -source 8 -target 8. This is the legacy behaviour.
c.targetOpenJDK9 = false
default:
return fmt.Errorf(`Invalid value for EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9, should be "" or "true"`)
return fmt.Errorf(`Invalid value for EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9, should be "", "true", or "false"`)
}
return nil