Use flexible types in DesugaredMethodList api

Bug: b/302055774
Change-Id: I97d2777cf15b362cd4881e1202c923a3ceddecf6
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/AbstractGenerateFiles.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/AbstractGenerateFiles.java
index 96e3e18..48e9575 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/AbstractGenerateFiles.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/AbstractGenerateFiles.java
@@ -4,26 +4,20 @@
 
 package com.android.tools.r8.ir.desugar.desugaredlibrary.lint;
 
+import com.android.tools.r8.ClassFileResourceProvider;
+import com.android.tools.r8.ProgramResourceProvider;
 import com.android.tools.r8.StringResource;
-import com.android.tools.r8.dex.ApplicationReader;
-import com.android.tools.r8.graph.DexApplication;
 import com.android.tools.r8.graph.DexItemFactory;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.DesugaredLibrarySpecification;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.DesugaredLibrarySpecificationParser;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.MachineDesugaredLibrarySpecification;
 import com.android.tools.r8.utils.AndroidApiLevel;
-import com.android.tools.r8.utils.AndroidApp;
 import com.android.tools.r8.utils.InternalOptions;
 import com.android.tools.r8.utils.Reporter;
-import com.android.tools.r8.utils.ThreadUtils;
-import com.android.tools.r8.utils.Timing;
-import com.google.common.collect.ImmutableList;
-import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.Collection;
-import java.util.concurrent.ExecutorService;
 
 public abstract class AbstractGenerateFiles {
 
@@ -39,63 +33,36 @@
           .getOptions();
 
   final DesugaredLibrarySpecification desugaredLibrarySpecification;
-  final Path desugaredLibrarySpecificationPath;
-  final Collection<Path> desugaredLibraryImplementation;
+  final StringResource desugaredLibrarySpecificationResource;
+  final Collection<ProgramResourceProvider> desugaredLibraryImplementation;
   final Path output;
-  final Path androidJar;
+  final Collection<ClassFileResourceProvider> androidJar;
 
   AbstractGenerateFiles(
-      String desugarConfigurationPath,
-      String desugarImplementationPath,
-      String output,
-      String androidJarPath) {
-    this(
-        desugarConfigurationPath == null ? null : Paths.get(desugarConfigurationPath),
-        desugarImplementationPath == null
-            ? ImmutableList.of()
-            : ImmutableList.of(Paths.get(desugarImplementationPath)),
-        Paths.get(output),
-        Paths.get(androidJarPath));
-  }
-
-  AbstractGenerateFiles(
-      Path desugarConfigurationPath,
-      Collection<Path> desugarImplementationPath,
+      StringResource desugaredLibrarySpecificationResource,
+      Collection<ProgramResourceProvider> desugarImplementation,
       Path output,
-      Path androidJar) {
+      Collection<ClassFileResourceProvider> androidJar) {
     assert androidJar != null;
-    this.desugaredLibrarySpecificationPath = desugarConfigurationPath;
+    this.desugaredLibrarySpecificationResource = desugaredLibrarySpecificationResource;
     this.androidJar = androidJar;
-    this.desugaredLibrarySpecification = readDesugaredLibraryConfiguration();
-    this.desugaredLibraryImplementation = desugarImplementationPath;
+    this.desugaredLibrarySpecification = readDesugaredLibrarySpecification();
+    this.desugaredLibraryImplementation = desugarImplementation;
     this.output = output;
   }
 
-  private DesugaredLibrarySpecification readDesugaredLibraryConfiguration() {
-    if (desugaredLibrarySpecificationPath == null) {
+  private DesugaredLibrarySpecification readDesugaredLibrarySpecification() {
+    if (desugaredLibrarySpecificationResource == null) {
       return MachineDesugaredLibrarySpecification.empty();
     }
     return DesugaredLibrarySpecificationParser.parseDesugaredLibrarySpecification(
-        StringResource.fromFile(desugaredLibrarySpecificationPath),
+        desugaredLibrarySpecificationResource,
         factory,
         reporter,
         false,
         AndroidApiLevel.B.getLevel());
   }
 
-  private static DexApplication createApp(Path androidJar, InternalOptions options)
-      throws IOException {
-    AndroidApp.Builder builder = AndroidApp.builder();
-    AndroidApp inputApp = builder.addLibraryFiles(androidJar).build();
-    ApplicationReader applicationReader = new ApplicationReader(inputApp, options, Timing.empty());
-    ExecutorService executorService = ThreadUtils.getExecutorService(options);
-    assert !options.ignoreJavaLibraryOverride;
-    options.ignoreJavaLibraryOverride = true;
-    DexApplication app = applicationReader.read(executorService);
-    options.ignoreJavaLibraryOverride = false;
-    return app;
-  }
-
   abstract AndroidApiLevel run() throws Exception;
 
   // TODO(b/289365156): Move this out.
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/DesugaredMethodsList.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/DesugaredMethodsList.java
index cfe94c5..731942c 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/DesugaredMethodsList.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/DesugaredMethodsList.java
@@ -6,24 +6,36 @@
 
 import static java.lang.Integer.parseInt;
 
+import com.android.tools.r8.ArchiveClassFileProvider;
+import com.android.tools.r8.ArchiveProgramResourceProvider;
+import com.android.tools.r8.ClassFileResourceProvider;
 import com.android.tools.r8.Keep;
+import com.android.tools.r8.ProgramResourceProvider;
+import com.android.tools.r8.StringConsumer;
+import com.android.tools.r8.StringResource;
 import com.android.tools.r8.utils.AndroidApiLevel;
 import com.android.tools.r8.utils.StringUtils;
-import java.nio.file.Path;
+import com.google.common.collect.ImmutableList;
+import java.nio.file.Paths;
+import java.util.Collection;
+import java.util.List;
 
 @Keep
 public class DesugaredMethodsList extends GenerateDesugaredLibraryLintFiles {
 
   private final AndroidApiLevel minApi;
 
-  private DesugaredMethodsList(
+  private final StringConsumer outputConsumer;
+
+  DesugaredMethodsList(
       int minApi,
-      String desugarConfigurationPath,
-      String desugarImplementationPath,
-      String ouputFile,
-      String androidJarPath) {
-    super(desugarConfigurationPath, desugarImplementationPath, ouputFile, androidJarPath);
+      StringResource desugarConfiguration,
+      Collection<ProgramResourceProvider> desugarImplementation,
+      StringConsumer outputConsumer,
+      Collection<ClassFileResourceProvider> androidJar) {
+    super(desugarConfiguration, desugarImplementation, null, androidJar);
     this.minApi = AndroidApiLevel.getAndroidApiLevel(minApi);
+    this.outputConsumer = outputConsumer;
   }
 
   @Override
@@ -32,7 +44,7 @@
         desugaredLibrarySpecification.getRequiredCompilationApiLevel();
     SupportedClasses supportedMethods =
         new SupportedClassesGenerator(options, androidJar, minApi, true)
-            .run(desugaredLibraryImplementation, desugaredLibrarySpecificationPath);
+            .run(desugaredLibraryImplementation, desugaredLibrarySpecificationResource);
     System.out.println(
         "Generating lint files for "
             + getDebugIdentifier()
@@ -44,15 +56,36 @@
   }
 
   @Override
-  Path lintFile(
-      AndroidApiLevel compilationApiLevel, AndroidApiLevel minApiLevel, String extension) {
-    return output;
+  void writeOutput(
+      AndroidApiLevel compilationApiLevel,
+      AndroidApiLevel minApiLevel,
+      List<String> desugaredApisSignatures) {
+    for (String desugaredApisSignature : desugaredApisSignatures) {
+      outputConsumer.accept(desugaredApisSignature, options.reporter);
+      outputConsumer.accept("\n", options.reporter);
+    }
+    outputConsumer.finished(options.reporter);
+  }
+
+  private static StringResource getSpecificationArg(String arg) {
+    return arg == null ? null : StringResource.fromFile(Paths.get(arg));
+  }
+
+  private static Collection<ProgramResourceProvider> getImplementationArg(String arg) {
+    if (arg == null) {
+      return ImmutableList.of();
+    }
+    return ImmutableList.of(ArchiveProgramResourceProvider.fromArchive(Paths.get(arg)));
   }
 
   public static void main(String[] args) throws Exception {
     if (args.length == 4 || args.length == 5) {
       new DesugaredMethodsList(
-              parseInt(args[0]), args[1], args[2], args[3], getAndroidJarPath(args, 5))
+              parseInt(args[0]),
+              getSpecificationArg(args[1]),
+              getImplementationArg(args[2]),
+              new StringConsumer.FileConsumer(Paths.get(args[3])),
+              ImmutableList.of(new ArchiveClassFileProvider(Paths.get(getAndroidJarPath(args, 5)))))
           .run();
       return;
     }
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/GenerateDesugaredLibraryLintFiles.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/GenerateDesugaredLibraryLintFiles.java
index 09abea0..defba4b 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/GenerateDesugaredLibraryLintFiles.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/GenerateDesugaredLibraryLintFiles.java
@@ -4,12 +4,18 @@
 
 package com.android.tools.r8.ir.desugar.desugaredlibrary.lint;
 
+import com.android.tools.r8.ArchiveClassFileProvider;
+import com.android.tools.r8.ArchiveProgramResourceProvider;
+import com.android.tools.r8.ClassFileResourceProvider;
+import com.android.tools.r8.ProgramResourceProvider;
+import com.android.tools.r8.StringResource;
 import com.android.tools.r8.graph.DexMethod;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.lint.SupportedClasses.MethodAnnotation;
 import com.android.tools.r8.utils.AndroidApiLevel;
 import com.android.tools.r8.utils.DescriptorUtils;
 import com.android.tools.r8.utils.FileUtils;
 import com.android.tools.r8.utils.StringUtils;
+import com.google.common.collect.ImmutableList;
 import java.io.File;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -18,33 +24,18 @@
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.List;
-import java.util.Set;
 
 public class GenerateDesugaredLibraryLintFiles extends AbstractGenerateFiles {
 
   // Only recent versions of studio support the format with fields.
   private static final boolean FORMAT_WITH_FIELD = true;
 
-  public static GenerateDesugaredLibraryLintFiles createForTesting(
-      Path specification, Set<Path> implementation, Path outputDirectory, Path androidJar) {
-    return new GenerateDesugaredLibraryLintFiles(
-        specification, implementation, outputDirectory, androidJar);
-  }
-
   public GenerateDesugaredLibraryLintFiles(
-      String desugarConfigurationPath,
-      String desugarImplementationPath,
-      String outputDirectory,
-      String androidJarPath) {
-    super(desugarConfigurationPath, desugarImplementationPath, outputDirectory, androidJarPath);
-  }
-
-  GenerateDesugaredLibraryLintFiles(
-      Path desugarConfigurationPath,
-      Collection<Path> desugarImplementationPath,
-      Path outputDirectory,
-      Path androidJar) {
-    super(desugarConfigurationPath, desugarImplementationPath, outputDirectory, androidJar);
+      StringResource desugarConfiguration,
+      Collection<ProgramResourceProvider> desugarImplementation,
+      Path output,
+      Collection<ClassFileResourceProvider> androidJar) {
+    super(desugarConfiguration, desugarImplementation, output, androidJar);
   }
 
   private String lintBaseFileName(
@@ -52,7 +43,8 @@
     return "desugared_apis_" + compilationApiLevel.getLevel() + "_" + minApiLevel.getLevel();
   }
 
-  Path lintFile(AndroidApiLevel compilationApiLevel, AndroidApiLevel minApiLevel, String extension)
+  private Path lintFile(
+      AndroidApiLevel compilationApiLevel, AndroidApiLevel minApiLevel, String extension)
       throws Exception {
     Path directory = output.resolve("compile_api_level_" + compilationApiLevel.getLevel());
     Files.createDirectories(directory);
@@ -115,6 +107,14 @@
 
     // Write a plain text file with the desugared APIs.
     desugaredApisSignatures.sort(Comparator.naturalOrder());
+    writeOutput(compilationApiLevel, minApiLevel, desugaredApisSignatures);
+  }
+
+  void writeOutput(
+      AndroidApiLevel compilationApiLevel,
+      AndroidApiLevel minApiLevel,
+      List<String> desugaredApisSignatures)
+      throws Exception {
     FileUtils.writeTextFile(
         lintFile(compilationApiLevel, minApiLevel, ".txt"), desugaredApisSignatures);
   }
@@ -158,7 +158,7 @@
         desugaredLibrarySpecification.getRequiredCompilationApiLevel();
     SupportedClasses supportedMethods =
         new SupportedClassesGenerator(options, androidJar)
-            .run(desugaredLibraryImplementation, desugaredLibrarySpecificationPath);
+            .run(desugaredLibraryImplementation, desugaredLibrarySpecificationResource);
     System.out.println(
         "Generating lint files for "
             + getDebugIdentifier()
@@ -173,7 +173,11 @@
 
   public static void main(String[] args) throws Exception {
     if (args.length == 3 || args.length == 4) {
-      new GenerateDesugaredLibraryLintFiles(args[0], args[1], args[2], getAndroidJarPath(args, 4))
+      new GenerateDesugaredLibraryLintFiles(
+              StringResource.fromFile(Paths.get(args[0])),
+              ImmutableList.of(ArchiveProgramResourceProvider.fromArchive(Paths.get(args[1]))),
+              Paths.get(args[2]),
+              ImmutableList.of(new ArchiveClassFileProvider(Paths.get(getAndroidJarPath(args, 4)))))
           .run();
       return;
     }
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/GenerateHtmlDoc.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/GenerateHtmlDoc.java
index 5889b77..3c341fa 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/GenerateHtmlDoc.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/GenerateHtmlDoc.java
@@ -4,6 +4,11 @@
 
 package com.android.tools.r8.ir.desugar.desugaredlibrary.lint;
 
+import com.android.tools.r8.ArchiveClassFileProvider;
+import com.android.tools.r8.ArchiveProgramResourceProvider;
+import com.android.tools.r8.ClassFileResourceProvider;
+import com.android.tools.r8.ProgramResourceProvider;
+import com.android.tools.r8.StringResource;
 import com.android.tools.r8.graph.CfCode.LocalVariableInfo;
 import com.android.tools.r8.graph.ClassAccessFlags;
 import com.android.tools.r8.graph.DexEncodedField;
@@ -19,9 +24,13 @@
 import com.android.tools.r8.utils.AndroidApiLevel;
 import com.android.tools.r8.utils.ListUtils;
 import com.android.tools.r8.utils.StringUtils;
+import com.google.common.collect.ImmutableList;
 import java.io.PrintStream;
 import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
@@ -37,12 +46,11 @@
   private static final String SUP_4 = "<sup>4</sup>";
 
   public GenerateHtmlDoc(
-      String desugarConfigurationPath,
-      String desugarImplementationPath,
-      String outputDirectory,
-      String androidJarPath)
-      throws Exception {
-    super(desugarConfigurationPath, desugarImplementationPath, outputDirectory, androidJarPath);
+      StringResource desugarSpecification,
+      Collection<ProgramResourceProvider> desugarImplementation,
+      Path outputDirectory,
+      Collection<ClassFileResourceProvider> androidJar) {
+    super(desugarSpecification, desugarImplementation, outputDirectory, androidJar);
   }
 
   private static class StringBuilderWithIndent {
@@ -558,7 +566,7 @@
 
     SupportedClasses supportedClasses =
         new SupportedClassesGenerator(options, androidJar)
-            .run(desugaredLibraryImplementation, desugaredLibrarySpecificationPath);
+            .run(desugaredLibraryImplementation, desugaredLibrarySpecificationResource);
 
     // Full classes added.
     supportedClasses.forEachClass(supportedClass -> generateClassHTML(ps, supportedClass));
@@ -568,7 +576,13 @@
   public static void main(String[] args) throws Exception {
     if (args[0].equals("--generate-api-docs")) {
       if (args.length == 4 || args.length == 5) {
-        new GenerateHtmlDoc(args[1], args[2], args[3], getAndroidJarPath(args, 5)).run();
+        new GenerateHtmlDoc(
+                StringResource.fromFile(Paths.get(args[1])),
+                ImmutableList.of(ArchiveProgramResourceProvider.fromArchive(Paths.get(args[2]))),
+                Paths.get(args[3]),
+                ImmutableList.of(
+                    new ArchiveClassFileProvider(Paths.get(getAndroidJarPath(args, 4)))))
+            .run();
         return;
       }
     }
diff --git a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/SupportedClassesGenerator.java b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/SupportedClassesGenerator.java
index 98b73ce..4435768 100644
--- a/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/SupportedClassesGenerator.java
+++ b/src/main/java/com/android/tools/r8/ir/desugar/desugaredlibrary/lint/SupportedClassesGenerator.java
@@ -6,6 +6,8 @@
 
 import static com.android.tools.r8.ir.desugar.desugaredlibrary.lint.AbstractGenerateFiles.MAX_TESTED_ANDROID_API_LEVEL;
 
+import com.android.tools.r8.ClassFileResourceProvider;
+import com.android.tools.r8.ProgramResourceProvider;
 import com.android.tools.r8.StringResource;
 import com.android.tools.r8.androidapi.ComputedApiLevel;
 import com.android.tools.r8.dex.ApplicationReader;
@@ -44,7 +46,6 @@
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import java.io.IOException;
-import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Comparator;
@@ -60,12 +61,17 @@
   private final SupportedClasses.Builder builder = SupportedClasses.builder();
   private final boolean addBackports;
 
-  public SupportedClassesGenerator(InternalOptions options, Path androidJar) throws IOException {
+  public SupportedClassesGenerator(
+      InternalOptions options, Collection<ClassFileResourceProvider> androidJar)
+      throws IOException {
     this(options, androidJar, AndroidApiLevel.B, false);
   }
 
   public SupportedClassesGenerator(
-      InternalOptions options, Path androidJar, AndroidApiLevel minApi, boolean addBackports)
+      InternalOptions options,
+      Collection<ClassFileResourceProvider> androidJar,
+      AndroidApiLevel minApi,
+      boolean addBackports)
       throws IOException {
     this.options = options;
     this.appForMax = createAppForMax(androidJar);
@@ -73,7 +79,9 @@
     this.addBackports = addBackports;
   }
 
-  public SupportedClasses run(Collection<Path> desugaredLibraryImplementation, Path specification)
+  public SupportedClasses run(
+      Collection<ProgramResourceProvider> desugaredLibraryImplementation,
+      StringResource specification)
       throws IOException {
     // First analyze everything which is supported when desugaring for api 1.
     collectSupportedMembersInMinApi(desugaredLibraryImplementation, specification);
@@ -125,7 +133,7 @@
     return fullySupported;
   }
 
-  private void annotatePartialDesugaringMembers(Path specification) throws IOException {
+  private void annotatePartialDesugaringMembers(StringResource specification) throws IOException {
     if (builder.hasOnlyExtraMethods()) {
       return;
     }
@@ -252,7 +260,9 @@
   }
 
   private void collectSupportedMembersInMinApi(
-      Collection<Path> desugaredLibraryImplementation, Path specification) throws IOException {
+      Collection<ProgramResourceProvider> desugaredLibraryImplementation,
+      StringResource specification)
+      throws IOException {
 
     MachineDesugaredLibrarySpecification machineSpecification =
         getMachineSpecification(minApi, specification);
@@ -261,8 +271,11 @@
     options.resetDesugaredLibrarySpecificationForTesting();
     options.setDesugaredLibrarySpecification(machineSpecification);
 
-    AndroidApp implementation =
-        AndroidApp.builder().addProgramFiles(desugaredLibraryImplementation).build();
+    AndroidApp.Builder appBuilder = AndroidApp.builder();
+    for (ProgramResourceProvider programResource : desugaredLibraryImplementation) {
+      appBuilder.addProgramResourceProvider(programResource);
+    }
+    AndroidApp implementation = appBuilder.build();
     DirectMappedDexApplication implementationApplication =
         new ApplicationReader(implementation, options, Timing.empty()).read().toDirect();
 
@@ -425,23 +438,23 @@
   }
 
   private MachineDesugaredLibrarySpecification getMachineSpecification(
-      AndroidApiLevel api, Path specification) throws IOException {
+      AndroidApiLevel api, StringResource specification) throws IOException {
     if (specification == null) {
       return MachineDesugaredLibrarySpecification.empty();
     }
     DesugaredLibrarySpecification librarySpecification =
         DesugaredLibrarySpecificationParser.parseDesugaredLibrarySpecification(
-            StringResource.fromFile(specification),
-            options.itemFactory,
-            options.reporter,
-            false,
-            api.getLevel());
+            specification, options.itemFactory, options.reporter, false, api.getLevel());
     return librarySpecification.toMachineSpecification(appForMax, Timing.empty());
   }
 
-  private DirectMappedDexApplication createAppForMax(Path androidJar) throws IOException {
+  private DirectMappedDexApplication createAppForMax(
+      Collection<ClassFileResourceProvider> androidJar) throws IOException {
     AndroidApp.Builder builder = AndroidApp.builder();
-    AndroidApp inputApp = builder.addLibraryFiles(androidJar).build();
+    for (ClassFileResourceProvider libraryResource : androidJar) {
+      builder.addLibraryResourceProvider(libraryResource);
+    }
+    AndroidApp inputApp = builder.build();
     ApplicationReader applicationReader = new ApplicationReader(inputApp, options, Timing.empty());
     ExecutorService executorService = ThreadUtils.getExecutorService(options);
     assert !options.ignoreJavaLibraryOverride;
diff --git a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/ExtractWrapperTypesTest.java b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/ExtractWrapperTypesTest.java
index 2ccc573..87d5720 100644
--- a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/ExtractWrapperTypesTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/ExtractWrapperTypesTest.java
@@ -25,7 +25,6 @@
 import com.android.tools.r8.graph.GenericSignature.TypeSignature;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.DesugaredLibrarySpecification;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.DesugaredLibrarySpecificationParser;
-import com.android.tools.r8.ir.desugar.desugaredlibrary.lint.GenerateDesugaredLibraryLintFiles;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.MachineDesugaredLibrarySpecification;
 import com.android.tools.r8.ir.desugar.desugaredlibrary.machinespecification.WrapperDescriptor;
 import com.android.tools.r8.naming.MemberNaming.MethodSignature;
@@ -501,20 +500,6 @@
     return existing;
   }
 
-  private CodeInspector getDesugaredApiJar() throws Exception {
-    Path out = temp.newFolder().toPath();
-    GenerateDesugaredLibraryLintFiles desugaredApi =
-        GenerateDesugaredLibraryLintFiles.createForTesting(
-            libraryDesugaringSpecification.getSpecification(),
-            libraryDesugaringSpecification.getDesugarJdkLibs(),
-            out,
-            ToolHelper.getAndroidJar(AndroidApiLevel.U));
-    AndroidApiLevel compileApi = desugaredApi.run();
-    return new CodeInspector(
-        out.resolve("compile_api_level_" + compileApi.getLevel())
-            .resolve("desugared_apis_" + compileApi.getLevel() + "_" + minApi.getLevel() + ".jar"));
-  }
-
   private boolean addType(
       Consumer<ClassReference> additions,
       String type,
diff --git a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/LintFilesTest.java b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/LintFilesTest.java
index ce9ae53..e07b779 100644
--- a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/LintFilesTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/LintFilesTest.java
@@ -13,6 +13,8 @@
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import com.android.tools.r8.ArchiveClassFileProvider;
+import com.android.tools.r8.ArchiveProgramResourceProvider;
 import com.android.tools.r8.StringResource;
 import com.android.tools.r8.TestParameters;
 import com.android.tools.r8.ToolHelper;
@@ -249,18 +251,18 @@
               ? ToolHelper.DESUGARED_JDK_8_LIB_JAR
               : LibraryDesugaringSpecification.getTempLibraryJDK11Undesugar();
       new GenerateHtmlDoc(
-              spec.getSpecification().toString(),
-              jdkLibJar.toString(),
-              html.toString(),
-              ANDROID_JAR_34)
+              StringResource.fromFile(spec.getSpecification()),
+              ImmutableList.of(ArchiveProgramResourceProvider.fromArchive(jdkLibJar)),
+              html,
+              ImmutableList.of(new ArchiveClassFileProvider(Paths.get(ANDROID_JAR_34))))
           .run(spec + ".html");
       Path lint = top.resolve("lint_" + spec);
       Files.createDirectories(lint);
       new GenerateDesugaredLibraryLintFiles(
-              spec.getSpecification().toString(),
-              jdkLibJar.toString(),
-              lint.toString(),
-              ANDROID_JAR_34)
+              StringResource.fromFile(spec.getSpecification()),
+              ImmutableList.of(ArchiveProgramResourceProvider.fromArchive(jdkLibJar)),
+              lint,
+              ImmutableList.of(new ArchiveClassFileProvider(Paths.get(ANDROID_JAR_34))))
           .run();
     }
   }
diff --git a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/PartialDesugaringTest.java b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/PartialDesugaringTest.java
index 1872678..74ac232 100644
--- a/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/PartialDesugaringTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/desugaredlibrary/PartialDesugaringTest.java
@@ -11,6 +11,10 @@
 import static com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification.getJdk8AndAll3Jdk11;
 import static org.junit.Assert.assertEquals;
 
+import com.android.tools.r8.ArchiveClassFileProvider;
+import com.android.tools.r8.ArchiveProgramResourceProvider;
+import com.android.tools.r8.ProgramResourceProvider;
+import com.android.tools.r8.StringResource;
 import com.android.tools.r8.TestParameters;
 import com.android.tools.r8.ToolHelper;
 import com.android.tools.r8.desugar.desugaredlibrary.test.LibraryDesugaringSpecification;
@@ -133,9 +137,17 @@
     options
         .getArtProfileOptions()
         .setAllowReadingEmptyArtProfileProvidersMultipleTimesForTesting(true);
+    Set<ProgramResourceProvider> programResources =
+        librarySpecification.getDesugarJdkLibs().stream()
+            .map(ArchiveProgramResourceProvider::fromArchive)
+            .collect(Collectors.toSet());
     SupportedClasses supportedClasses =
-        new SupportedClassesGenerator(options, ToolHelper.getAndroidJar(AndroidApiLevel.U))
-            .run(librarySpecification.getDesugarJdkLibs(), librarySpecification.getSpecification());
+        new SupportedClassesGenerator(
+                options,
+                ImmutableList.of(
+                    new ArchiveClassFileProvider(ToolHelper.getAndroidJar(AndroidApiLevel.U))))
+            .run(
+                programResources, StringResource.fromFile(librarySpecification.getSpecification()));
 
     for (AndroidApiLevel api : getRelevantApiLevels()) {