From db77e14d84258b81cf8e81cafe803e6f284cfd19 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 3 Dec 2020 19:25:39 +0000 Subject: [PATCH] Ensure that only one dex jar is chosen for each boot image library This change does not break modules like "core-oj" that are in multiple apexes, i.e. com.android.art, com.android.art.debug and com.android.art.testing because they all shared the same variant. So, the getBootImageJar() is only called once for that variant. Test: m droid Bug: 171061220 Change-Id: Ibf26da147af2b49ab9e4588030e8cd4002d04a7a --- java/dexpreopt_bootjars.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index da7f291a3..fc6d155de 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -495,6 +495,12 @@ func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootI bootDexJars := make(android.Paths, image.modules.Len()) ctx.VisitAllModules(func(module android.Module) { if i, j := getBootImageJar(ctx, image, module); i != -1 { + if existing := bootDexJars[i]; existing != nil { + ctx.Errorf("Multiple dex jars found for %s:%s - %s and %s", + image.modules.Apex(i), image.modules.Jar(i), existing, j) + return + } + bootDexJars[i] = j } })