Pass libraryToApex and apexNameToFragment mappings into CreateClasspathElements

Remove a usage of ApexInfo.InApexVariants by collecting the libraryToApex
and apexToFragment mappings while collecting the fragments and passing
them into CreateClasspathElements.

Bug: 372543712
Test: CreateClasspathElementTest
Change-Id: I03adc821b04bc01828f075f25bbb8124505859a7
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 24bb99d..27027f0 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -734,7 +734,8 @@
 	modules := make([]apexJarModulePair, 0, imageConfig.modules.Len())
 	for i := 0; i < imageConfig.modules.Len(); i++ {
 		found := false
-		for _, module := range gatherApexModulePairDepsWithTag(ctx, dexpreoptBootJar) {
+		dexpreoptBootJarModules, _ := gatherApexModulePairDepsWithTag(ctx, dexpreoptBootJar)
+		for _, module := range dexpreoptBootJarModules {
 			name := android.RemoveOptionalPrebuiltPrefix(module.Name())
 			if name == imageConfig.modules.Jar(i) {
 				modules = append(modules, apexJarModulePair{
@@ -817,6 +818,7 @@
 				"APEX '%[2]s' doesn't exist or is not added as a dependency of dex_bootjars",
 				pair.jarModule.Name(),
 				pair.apex)
+			return nil
 		}
 		bootclasspathFragmentInfo, _ := android.OtherModuleProvider(ctx, fragment, BootclasspathFragmentApexContentInfoProvider)
 		jar, err := bootclasspathFragmentInfo.DexBootJarPathForContentModule(pair.jarModule)