Merge "Linkerconfig with namespace contribution"
diff --git a/android/config.go b/android/config.go
index afc138b..4472036 100644
--- a/android/config.go
+++ b/android/config.go
@@ -658,10 +658,6 @@
 	return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
 }
 
-func (c *config) TargetsJava11() bool {
-	return c.IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_11")
-}
-
 // EnvDeps returns the environment variables this build depends on. The first
 // call to this function blocks future reads from the environment.
 func (c *config) EnvDeps() map[string]string {
diff --git a/cc/OWNERS b/cc/OWNERS
index 6d7c30a..811d881 100644
--- a/cc/OWNERS
+++ b/cc/OWNERS
@@ -1,4 +1,4 @@
 per-file ndk_*.go = danalbert@google.com
 per-file tidy.go = srhines@google.com, chh@google.com
-per-file lto.go,pgo.go = srhines@google.com, pirama@google.com, yikong@google.com
+per-file afdo.go,lto.go,pgo.go = srhines@google.com, pirama@google.com, yikong@google.com
 
diff --git a/cc/afdo.go b/cc/afdo.go
index f7639fa..d7cce77 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -93,7 +93,13 @@
 }
 
 func (afdo *afdo) begin(ctx BaseModuleContext) {
-	if afdo.Properties.Afdo && !ctx.static() && !ctx.Host() {
+	if ctx.Host() {
+		return
+	}
+	if ctx.static() && !ctx.staticBinary() {
+		return
+	}
+	if afdo.Properties.Afdo {
 		module := ctx.ModuleName()
 		if afdo.Properties.GetAfdoProfileFile(ctx, module).Valid() {
 			afdo.Properties.AfdoTarget = proptools.StringPtr(module)
diff --git a/java/base.go b/java/base.go
index 63328c8..a3eb8de 100644
--- a/java/base.go
+++ b/java/base.go
@@ -122,14 +122,6 @@
 		Javacflags []string
 	}
 
-	Openjdk11 struct {
-		// List of source files that should only be used when passing -source 1.9 or higher
-		Srcs []string `android:"path"`
-
-		// List of javac flags that should only be used when passing -source 1.9 or higher
-		Javacflags []string
-	}
-
 	// When compiling language level 9+ .java code in packages that are part of
 	// a system module, patch_module names the module that your sources and
 	// dependencies should be patched into. The Android runtime currently
@@ -976,9 +968,6 @@
 	if flags.javaVersion.usesJavaModules() {
 		j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
 	}
-	if ctx.Config().TargetsJava11() {
-		j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk11.Srcs...)
-	}
 
 	srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
 	if hasSrcExt(srcFiles.Strings(), ".proto") {
diff --git a/java/java.go b/java/java.go
index bb7c32b..e3e9721 100644
--- a/java/java.go
+++ b/java/java.go
@@ -450,14 +450,8 @@
 		return normalizeJavaVersion(ctx, javaVersion)
 	} else if ctx.Device() {
 		return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx))
-	} else if ctx.Config().TargetsJava11() {
-		// Temporary experimental flag to be able to try and build with
-		// java version 11 options.  The flag, if used, just sets Java
-		// 11 as the default version, leaving any components that
-		// target an older version intact.
-		return JAVA_VERSION_11
 	} else {
-		return JAVA_VERSION_9
+		return JAVA_VERSION_11
 	}
 }
 
diff --git a/java/sdk.go b/java/sdk.go
index 756a24d..0dddd40 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -55,14 +55,10 @@
 		return JAVA_VERSION_7
 	} else if sdk.FinalOrFutureInt() <= 29 {
 		return JAVA_VERSION_8
-	} else if ctx.Config().TargetsJava11() {
-		// Temporary experimental flag to be able to try and build with
-		// java version 11 options. The flag, if used, just sets Java
-		// 11 as the default version, leaving any components that
-		// target an older version intact.
-		return JAVA_VERSION_11
-	} else {
+	} else if sdk.FinalOrFutureInt() <= 31 {
 		return JAVA_VERSION_9
+	} else {
+		return JAVA_VERSION_11
 	}
 }
 
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 7849f96..57ab268 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1392,10 +1392,6 @@
 			Srcs       []string
 			Javacflags []string
 		}
-		Openjdk11 struct {
-			Srcs       []string
-			Javacflags []string
-		}
 		Dist struct {
 			Targets []string
 			Dest    *string
@@ -1422,8 +1418,6 @@
 	}
 	props.Openjdk9.Srcs = module.properties.Openjdk9.Srcs
 	props.Openjdk9.Javacflags = module.properties.Openjdk9.Javacflags
-	props.Openjdk11.Srcs = module.properties.Openjdk11.Srcs
-	props.Openjdk11.Javacflags = module.properties.Openjdk11.Javacflags
 	// We compile the stubs for 1.8 in line with the main android.jar stubs, and potential
 	// interop with older developer tools that don't support 1.9.
 	props.Java_version = proptools.StringPtr("1.8")