summaryrefslogtreecommitdiff
path: root/dexpreopt/class_loader_context_test.go
diff options
context:
space:
mode:
authorUlya Trafimovich <skvadrik@google.com>2020-11-03 15:33:03 +0000
committerUlya Trafimovich <skvadrik@google.com>2020-11-16 12:17:30 +0000
commit5e13a7307e36ae261a64abd2a834304aae66b879 (patch)
tree231b858889b471a748f677d86125f7b8450d7542 /dexpreopt/class_loader_context_test.go
parent8cbc5d269b20b5743679bfb8684ed174dcf58a30 (diff)
Disallow adding nested conditional class loader context.
Nested conditional context doesn't make sense because conditional context is only needed for compatibility libraries, and those are only used by apps, and apps are always at the root of class loader context tree. Therefore, trying to add conditional nested context can only mean an error somewhere on the way. Test: lunch aosp_cf_x86_phone-userdebug && m Bug: 132357300 Change-Id: Iadeaaf89fdb11cb23b107c6fb074b1bc765256be
Diffstat (limited to 'dexpreopt/class_loader_context_test.go')
-rw-r--r--dexpreopt/class_loader_context_test.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/dexpreopt/class_loader_context_test.go b/dexpreopt/class_loader_context_test.go
index 269a0dbc0..aed354367 100644
--- a/dexpreopt/class_loader_context_test.go
+++ b/dexpreopt/class_loader_context_test.go
@@ -194,6 +194,16 @@ func TestCLCMaybeAdd(t *testing.T) {
})
}
+// An attempt to add conditional nested subcontext should fail.
+func TestCLCNestedConditional(t *testing.T) {
+ ctx := testContext()
+ m1 := make(ClassLoaderContextMap)
+ m1.AddContextForSdk(ctx, 42, "a", buildPath(ctx, "a"), installPath(ctx, "a"), nil)
+ m := make(ClassLoaderContextMap)
+ err := m.addContext(ctx, AnySdkVersion, "b", buildPath(ctx, "b"), installPath(ctx, "b"), true, m1)
+ checkError(t, err, "nested class loader context shouldn't have conditional part")
+}
+
func checkError(t *testing.T, have error, want string) {
if have == nil {
t.Errorf("\nwant error: '%s'\nhave: none", want)