Merge "Add test for parse error" into main
diff --git a/aconfig/codegen/cc_aconfig_library_test.go b/aconfig/codegen/cc_aconfig_library_test.go
index d01d13b..2f6c1a6 100644
--- a/aconfig/codegen/cc_aconfig_library_test.go
+++ b/aconfig/codegen/cc_aconfig_library_test.go
@@ -74,11 +74,6 @@
     		srcs: ["libaconfig_storage_read_api_cc.cc"],
 			}
 
-			cc_library {
-    		name: "libaconfig_storage_protos_cc",
-    		srcs: ["libaconfig_storage_protos_cc.cc"],
-			}
-
 			cc_aconfig_library {
 				name: "my_cc_aconfig_library",
 				aconfig_declarations: "my_aconfig_declarations",
@@ -137,12 +132,6 @@
     		srcs: ["libaconfig_storage_read_api_cc.cc"],
 			}
 
-			cc_library {
-    		name: "libaconfig_storage_protos_cc",
-    		srcs: ["libaconfig_storage_protos_cc.cc"],
-			}
-
-
 			cc_aconfig_library {
 				name: "my_cc_aconfig_library",
 				aconfig_declarations: "my_aconfig_declarations",
@@ -214,12 +203,6 @@
 			srcs: ["libaconfig_storage_read_api_cc.cc"],
 			vendor_available: true,
 		}
-
-		cc_library {
-			name: "libaconfig_storage_protos_cc",
-			srcs: ["libaconfig_storage_protos_cc.cc"],
-			vendor_available: true,
-		}
 	`
 	result := android.GroupFixturePreparers(
 		PrepareForTestWithAconfigBuildComponents,
diff --git a/android/config.go b/android/config.go
index 76c590a..6007451 100644
--- a/android/config.go
+++ b/android/config.go
@@ -827,6 +827,10 @@
 	return value == "0" || value == "n" || value == "no" || value == "off" || value == "false"
 }
 
+func (c *config) TargetsJava21() bool {
+	return c.IsEnvTrue("EXPERIMENTAL_TARGET_JAVA_VERSION_21")
+}
+
 // 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/apex/aconfig_test.go b/apex/aconfig_test.go
index 726041c..14c0b63 100644
--- a/apex/aconfig_test.go
+++ b/apex/aconfig_test.go
@@ -23,6 +23,7 @@
 	"android/soong/genrule"
 	"android/soong/java"
 	"android/soong/rust"
+
 	"github.com/google/blueprint/proptools"
 )
 
@@ -173,10 +174,6 @@
 					name: "libaconfig_storage_read_api_cc",
 					srcs: ["libaconfig_storage_read_api_cc.cc"],
 				}
-				cc_library {
-					name: "libaconfig_storage_protos_cc",
-					srcs: ["libaconfig_storage_protos_cc.cc"],
-				}
 				aconfig_declarations {
 					name: "my_aconfig_declarations_bar",
 					package: "com.example.package",
@@ -436,10 +433,6 @@
 					name: "libaconfig_storage_read_api_cc",
 					srcs: ["libaconfig_storage_read_api_cc.cc"],
 				}
-				cc_library {
-					name: "libaconfig_storage_protos_cc",
-					srcs: ["libaconfig_storage_protos_cc.cc"],
-				}
 				aconfig_declarations {
 					name: "my_aconfig_declarations_foo",
 					package: "com.example.package",
@@ -501,10 +494,6 @@
 					name: "libaconfig_storage_read_api_cc",
 					srcs: ["libaconfig_storage_read_api_cc.cc"],
 				}
-				cc_library {
-					name: "libaconfig_storage_protos_cc",
-					srcs: ["libaconfig_storage_protos_cc.cc"],
-				}
 				aconfig_declarations {
 					name: "my_aconfig_declarations_foo",
 					package: "com.example.package",
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 965b4be..4cac0cc 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -10709,10 +10709,6 @@
 			name: "libaconfig_storage_read_api_cc",
 			srcs: ["libaconfig_storage_read_api_cc.cc"],
 		}
-		cc_library {
-			name: "libaconfig_storage_protos_cc",
-			srcs: ["libaconfig_storage_protos_cc.cc"],
-		}
 	`)
 
 	mod := ctx.ModuleForTests("myapex", "android_common_myapex")
diff --git a/java/java.go b/java/java.go
index e3f4824..9fe7a2f 100644
--- a/java/java.go
+++ b/java/java.go
@@ -567,6 +567,12 @@
 		return normalizeJavaVersion(ctx, javaVersion)
 	} else if ctx.Device() {
 		return defaultJavaLanguageVersion(ctx, sdkContext.SdkVersion(ctx))
+	} else if ctx.Config().TargetsJava21() {
+		// Temporary experimental flag to be able to try and build with
+		// java version 21 options.  The flag, if used, just sets Java
+		// 21 as the default version, leaving any components that
+		// target an older version intact.
+		return JAVA_VERSION_21
 	} else {
 		return JAVA_VERSION_17
 	}
diff --git a/java/sdk.go b/java/sdk.go
index d972c19..4ef4ee2 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -65,6 +65,12 @@
 		return JAVA_VERSION_9
 	} else if sdk.FinalOrFutureInt() <= 33 {
 		return JAVA_VERSION_11
+	} else if ctx.Config().TargetsJava21() {
+		// Temporary experimental flag to be able to try and build with
+		// java version 21 options.  The flag, if used, just sets Java
+		// 21 as the default version, leaving any components that
+		// target an older version intact.
+		return JAVA_VERSION_21
 	} else {
 		return JAVA_VERSION_17
 	}