Merge "Enable Java language level 9 by default."

This commit is contained in:
Pete Gillin
2019-10-17 10:38:35 +00:00
committed by Gerrit Code Review
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 { func (c *config) fromEnv() error {
switch c.Getenv("EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9") { switch c.Getenv("EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9") {
case "": case "", "true":
// Nothing, this is the default // Use -source 9 -target 9. This is the default.
case "true":
// Use -source 9 -target 9
c.targetOpenJDK9 = true c.targetOpenJDK9 = true
case "false":
// Use -source 8 -target 8. This is the legacy behaviour.
c.targetOpenJDK9 = false
default: 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 return nil

View File

@@ -1095,8 +1095,10 @@ func TestPatchModule(t *testing.T) {
` `
t.Run("Java language level 8", func(t *testing.T) { t.Run("Java language level 8", func(t *testing.T) {
// Test default javac -source 1.8 -target 1.8 // Test with legacy javac -source 1.8 -target 1.8
ctx, _ := testJava(t, bp) config := testConfig(map[string]string{"EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9": "false"})
ctx := testContext(bp, nil)
run(t, ctx, config)
checkPatchModuleFlag(t, ctx, "foo", "") checkPatchModuleFlag(t, ctx, "foo", "")
checkPatchModuleFlag(t, ctx, "bar", "") checkPatchModuleFlag(t, ctx, "bar", "")
@@ -1104,10 +1106,8 @@ func TestPatchModule(t *testing.T) {
}) })
t.Run("Java language level 9", func(t *testing.T) { t.Run("Java language level 9", func(t *testing.T) {
// Test again with javac -source 9 -target 9 // Test with default javac -source 9 -target 9
config := testConfig(map[string]string{"EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9": "true"}) ctx, _ := testJava(t, bp)
ctx := testContext(bp, nil)
run(t, ctx, config)
checkPatchModuleFlag(t, ctx, "foo", "") checkPatchModuleFlag(t, ctx, "foo", "")
expected := "java.base=.:" + buildDir expected := "java.base=.:" + buildDir

View File

@@ -279,9 +279,9 @@ func TestClasspath(t *testing.T) {
} }
} }
// Test with legacy javac -source 1.8 -target 1.8
t.Run("Java language level 8", func(t *testing.T) { t.Run("Java language level 8", func(t *testing.T) {
// Test default javac -source 1.8 -target 1.8 config := testConfig(map[string]string{"EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9": "false"})
config := testConfig(nil)
if testcase.unbundled { if testcase.unbundled {
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true) config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
} }
@@ -302,9 +302,9 @@ func TestClasspath(t *testing.T) {
} }
}) })
// Test again with javac -source 9 -target 9 // Test with default javac -source 9 -target 9
t.Run("Java language level 9", func(t *testing.T) { t.Run("Java language level 9", func(t *testing.T) {
config := testConfig(map[string]string{"EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9": "true"}) config := testConfig(nil)
if testcase.unbundled { if testcase.unbundled {
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true) config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
} }
@@ -327,7 +327,8 @@ func TestClasspath(t *testing.T) {
// Test again with PLATFORM_VERSION_CODENAME=REL // Test again with PLATFORM_VERSION_CODENAME=REL
t.Run("REL", func(t *testing.T) { t.Run("REL", func(t *testing.T) {
config := testConfig(nil) // TODO(b/115604102): This test should be rewritten with language level 9
config := testConfig(map[string]string{"EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9": "false"})
config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("REL") config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("REL")
config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(true) config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(true)