Use the full dexpreopt boot classpath when preopting with other images.

Bug: 119800099
Test: m
Change-Id: Ia9b34aa92ebb1b4de96ea0f8f290d798be19b2cf
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 6b93c10..9141f9e 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -98,6 +98,7 @@
 
 	global := dexpreoptGlobalConfig(ctx)
 	bootImage := defaultBootImageConfig(ctx)
+	defaultBootImage := bootImage
 	if global.UseApexImage {
 		bootImage = apexBootImageConfig(ctx)
 	}
@@ -165,8 +166,11 @@
 		Archs:           archs,
 		DexPreoptImages: images,
 
-		PreoptBootClassPathDexFiles:     bootImage.dexPaths.Paths(),
-		PreoptBootClassPathDexLocations: bootImage.dexLocations,
+		// We use the dex paths and dex locations of the default boot image, as it
+		// contains the full dexpreopt boot classpath. Other images may just contain a subset of
+		// the dexpreopt boot classpath.
+		PreoptBootClassPathDexFiles:     defaultBootImage.dexPaths.Paths(),
+		PreoptBootClassPathDexLocations: defaultBootImage.dexLocations,
 
 		PreoptExtractedApk: false,