From 81febc4500087425f1b3725a0f8fd83a68bc73b8 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 6 Oct 2020 16:54:02 +0100 Subject: [PATCH] Avoid panic when a boot jar is provided as a java_import Bug: 142938164 Test: m nothing Change-Id: I607009825f5946d7e1daa31dc1e4bb8f2609206d --- java/dexpreopt_bootjars.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 3addc1a74..7877031f8 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -238,6 +238,13 @@ func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) { dumpOatRules(ctx, d.defaultBootImage) } +func isHostdex(module android.Module) bool { + if lib, ok := module.(*Library); ok { + return Bool(lib.deviceProperties.Hostdex) + } + return false +} + // Inspect this module to see if it contains a bootclasspath dex jar. // Note that the same jar may occur in multiple modules. // This logic is tested in the apex package to avoid import cycle apex <-> java. @@ -264,7 +271,7 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul if image.name == artBootImageName { if isApexModule && len(apex.InApexes()) > 0 && allHavePrefix(apex.InApexes(), "com.android.art.") { // ok: found the jar in the ART apex - } else if isApexModule && apex.IsForPlatform() && Bool(module.(*Library).deviceProperties.Hostdex) { + } else if isApexModule && apex.IsForPlatform() && isHostdex(module) { // exception (skip and continue): special "hostdex" platform variant return -1, nil } else if name == "jacocoagent" && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {