Defer dexpreopt failure with missing implementation jar

Previously, if an implementation jar (Host) was not available to the
build it would panic when trying to generate the JSON representation of
the CLC. That prevents builds with missing implementation jars from
working even if those jars are never actually built.

This change defers the build failure until it is actually built.

Test: TARGET_PRODUCT=armv8 TARGET_BUILD_VARIANT=eng ./art/test/testrunner/run_build_test_target.py -j80 art-no-prebuild
      - run above in master-art before and after this change.
Bug: 202366925
Change-Id: I60a78a8bf6c13b83a9dceb5c43019a9e21f0b637
diff --git a/dexpreopt/class_loader_context.go b/dexpreopt/class_loader_context.go
index 1bdd040..658e8e2 100644
--- a/dexpreopt/class_loader_context.go
+++ b/dexpreopt/class_loader_context.go
@@ -598,11 +598,18 @@
 func toJsonClassLoaderContextRec(clcs []*ClassLoaderContext) []*jsonClassLoaderContext {
 	jClcs := make([]*jsonClassLoaderContext, len(clcs))
 	for i, clc := range clcs {
+		var host string
+		if clc.Host == nil {
+			// Defer build failure to when this CLC is actually used.
+			host = fmt.Sprintf("implementation-jar-for-%s-is-not-available.jar", clc.Name)
+		} else {
+			host = clc.Host.String()
+		}
 		jClcs[i] = &jsonClassLoaderContext{
 			Name:        clc.Name,
 			Optional:    clc.Optional,
 			Implicit:    clc.Implicit,
-			Host:        clc.Host.String(),
+			Host:        host,
 			Device:      clc.Device,
 			Subcontexts: toJsonClassLoaderContextRec(clc.Subcontexts),
 		}