Merge "Support using java_sdk_library components in stub_libs" into sc-dev
diff --git a/java/sdk.go b/java/sdk.go
index cbd873d..d1b899e 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -175,10 +175,24 @@
 		}
 	case android.SdkModule:
 		// TODO(146757305): provide .apk and .aidl that have more APIs for modules
-		return toModule([]string{"android_module_lib_stubs_current"}, "framework-res", nonUpdatableFrameworkAidlPath(ctx))
+		return sdkDep{
+			useModule:          true,
+			bootclasspath:      []string{"android_module_lib_stubs_current", config.DefaultLambdaStubsLibrary},
+			systemModules:      "core-module-lib-stubs-system-modules",
+			java9Classpath:     []string{"android_module_lib_stubs_current"},
+			frameworkResModule: "framework-res",
+			aidl:               android.OptionalPathForPath(nonUpdatableFrameworkAidlPath(ctx)),
+		}
 	case android.SdkSystemServer:
 		// TODO(146757305): provide .apk and .aidl that have more APIs for modules
-		return toModule([]string{"android_system_server_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx))
+		return sdkDep{
+			useModule:          true,
+			bootclasspath:      []string{"android_system_server_stubs_current", config.DefaultLambdaStubsLibrary},
+			systemModules:      "core-module-lib-stubs-system-modules",
+			java9Classpath:     []string{"android_system_server_stubs_current"},
+			frameworkResModule: "framework-res",
+			aidl:               android.OptionalPathForPath(sdkFrameworkAidlPath(ctx)),
+		}
 	default:
 		panic(fmt.Errorf("invalid sdk %q", sdkVersion.Raw))
 	}
diff --git a/java/sdk_test.go b/java/sdk_test.go
index 2b18465..bb595a5 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -219,7 +219,7 @@
 			name:           "module_current",
 			properties:     `sdk_version: "module_current",`,
 			bootclasspath:  []string{"android_module_lib_stubs_current", "core-lambda-stubs"},
-			system:         "core-current-stubs-system-modules",
+			system:         "core-module-lib-stubs-system-modules",
 			java9classpath: []string{"android_module_lib_stubs_current"},
 			aidl:           "-pout/soong/framework_non_updatable.aidl",
 		},
@@ -227,7 +227,7 @@
 			name:           "system_server_current",
 			properties:     `sdk_version: "system_server_current",`,
 			bootclasspath:  []string{"android_system_server_stubs_current", "core-lambda-stubs"},
-			system:         "core-current-stubs-system-modules",
+			system:         "core-module-lib-stubs-system-modules",
 			java9classpath: []string{"android_system_server_stubs_current"},
 			aidl:           "-pout/soong/framework.aidl",
 		},
diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go
index 7ffb056..992ade5 100644
--- a/java/systemserver_classpath_fragment.go
+++ b/java/systemserver_classpath_fragment.go
@@ -119,6 +119,11 @@
 	blueprint.BaseDependencyTag
 }
 
+// The systemserverclasspath_fragment contents must never depend on prebuilts.
+func (systemServerClasspathFragmentContentDependencyTag) ReplaceSourceWithPrebuilt() bool {
+	return false
+}
+
 // Contents of system server fragments in an apex are considered to be directly in the apex, as if
 // they were listed in java_libs.
 func (systemServerClasspathFragmentContentDependencyTag) CopyDirectlyInAnyApex() {}
diff --git a/java/testing.go b/java/testing.go
index 7b452f7..3ef51bd 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -312,6 +312,7 @@
 
 	systemModules := []string{
 		"core-current-stubs-system-modules",
+		"core-module-lib-stubs-system-modules",
 		"legacy-core-platform-api-stubs-system-modules",
 		"stable-core-platform-api-stubs-system-modules",
 	}