summaryrefslogtreecommitdiff
path: root/java/app_test.go
diff options
context:
space:
mode:
author Ulya Trafimovich <skvadrik@google.com> 2020-08-19 16:32:54 +0100
committer Ulya Trafimovich <skvadrik@google.com> 2020-08-27 11:47:15 +0100
commitfc24ad3d4e23ec992d47621601a98bebec6695bb (patch)
tree51b0060bb8c52a11031c9cc5603303e5007aca6e /java/app_test.go
parent03333d0e2f478aba21c3077dfdb69bd0593eaf3c (diff)
Propagate transitive SDK Java library dependencies to dexpreopt.
For some dependencies, like stubs, the SDK library may not be found at build time (either because the implementation library is not among the dependencies of the dexpreopted module, or because it's part of a prebuilt, or because it's missing from the build altogether). In such cases dexpreopt is useless, because dex2oat does not have access to the full classpath (unless the &-classpath is used). Therefore do not dexpreopt in such cases. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: If289088cfd103011ccb16165e95a97b30fd31b81
Diffstat (limited to 'java/app_test.go')
-rw-r--r--java/app_test.go31
1 files changed, 27 insertions, 4 deletions
diff --git a/java/app_test.go b/java/app_test.go
index 6b27124e4..7e7ae4102 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2542,6 +2542,19 @@ func TestUsesLibraries(t *testing.T) {
android_app {
name: "app",
srcs: ["a.java"],
+ libs: ["qux", "quuz"],
+ static_libs: ["static-runtime-helper"],
+ uses_libs: ["foo"],
+ sdk_version: "current",
+ optional_uses_libs: [
+ "bar",
+ "baz",
+ ],
+ }
+
+ android_app {
+ name: "app_with_stub_deps",
+ srcs: ["a.java"],
libs: ["qux", "quuz.stubs"],
static_libs: ["static-runtime-helper"],
uses_libs: ["foo"],
@@ -2572,6 +2585,7 @@ func TestUsesLibraries(t *testing.T) {
run(t, ctx, config)
app := ctx.ModuleForTests("app", "android_common")
+ appWithStubDeps := ctx.ModuleForTests("app_with_stub_deps", "android_common")
prebuilt := ctx.ModuleForTests("prebuilt", "android_common")
// Test that implicit dependencies on java_sdk_library instances are passed to the manifest.
@@ -2602,15 +2616,24 @@ func TestUsesLibraries(t *testing.T) {
t.Errorf("wanted %q in %q", w, cmd)
}
- // Test that only present libraries are preopted
+ // Test that all present libraries are preopted, including implicit SDK dependencies
cmd = app.Rule("dexpreopt").RuleParams.Command
-
- if w := `--target-classpath-for-sdk any /system/framework/foo.jar:/system/framework/bar.jar`; !strings.Contains(cmd, w) {
+ w := `--target-classpath-for-sdk any` +
+ ` /system/framework/foo.jar` +
+ `:/system/framework/quuz.jar` +
+ `:/system/framework/qux.jar` +
+ `:/system/framework/runtime-library.jar` +
+ `:/system/framework/bar.jar`
+ if !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}
- cmd = prebuilt.Rule("dexpreopt").RuleParams.Command
+ // TODO(skvadrik) fix dexpreopt for stub libraries for which the implementation is present
+ if appWithStubDeps.MaybeRule("dexpreopt").RuleParams.Command != "" {
+ t.Errorf("dexpreopt should be disabled for apps with dependencies on stub libraries")
+ }
+ cmd = prebuilt.Rule("dexpreopt").RuleParams.Command
if w := `--target-classpath-for-sdk any /system/framework/foo.jar:/system/framework/bar.jar`; !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}