BackportedMethodList api now forwards to desugaredMethodList
Change-Id: I208c3a0789f18c15c4a2ef453fca15a38e83bf14
diff --git a/src/main/java/com/android/tools/r8/BackportedMethodList.java b/src/main/java/com/android/tools/r8/BackportedMethodList.java
index bffd580..04c4886 100644
--- a/src/main/java/com/android/tools/r8/BackportedMethodList.java
+++ b/src/main/java/com/android/tools/r8/BackportedMethodList.java
@@ -4,14 +4,11 @@
package com.android.tools.r8;
-import com.android.tools.r8.graph.DexMethod;
-import com.android.tools.r8.ir.desugar.BackportedMethodRewriter;
-import com.android.tools.r8.utils.DescriptorUtils;
+import com.android.tools.r8.ir.desugar.desugaredlibrary.lint.DesugaredMethodsList;
+import com.android.tools.r8.ir.desugar.desugaredlibrary.lint.DesugaredMethodsListCommand;
+import com.android.tools.r8.origin.Origin;
import com.android.tools.r8.utils.ExceptionUtils;
-import com.android.tools.r8.utils.InternalOptions;
import com.android.tools.r8.utils.StringUtils;
-import com.android.tools.r8.utils.ThreadUtils;
-import java.util.concurrent.ExecutorService;
/**
* Tool to extract the list of methods which is backported by the D8 and R8 compilers.
@@ -62,13 +59,6 @@
" --version # Print the version of BackportedMethodList.",
" --help # Print this message.");
- private static String formatMethod(DexMethod method) {
- return DescriptorUtils.getClassBinaryNameFromDescriptor(method.holder.descriptor.toString())
- + '#'
- + method.name
- + method.proto.toDescriptorString();
- }
-
public static void run(BackportedMethodListCommand command) throws CompilationFailedException {
if (command.isPrintHelp()) {
System.out.println(USAGE_MESSAGE);
@@ -78,28 +68,25 @@
System.out.println("BackportedMethodList " + Version.getVersionString());
return;
}
- InternalOptions options = command.getInternalOptions();
+ DesugaredMethodsList.run(convert(command));
+ }
- ExecutorService executorService = ThreadUtils.getExecutorService(options);
- try {
- ExceptionUtils.withD8CompilationHandler(
- command.getReporter(),
- () -> {
- BackportedMethodRewriter.generateListOfBackportedMethods(
- command.getInputApp(), options, executorService)
- .stream()
- .map(BackportedMethodList::formatMethod)
- .sorted()
- .forEach(
- formattedMethod ->
- command
- .getBackportedMethodListConsumer()
- .accept(formattedMethod, command.getReporter()));
- command.getBackportedMethodListConsumer().finished(command.getReporter());
- });
- } finally {
- executorService.shutdown();
+ private static DesugaredMethodsListCommand convert(BackportedMethodListCommand command) {
+ DesugaredMethodsListCommand.Builder builder =
+ DesugaredMethodsListCommand.builder(command.getReporter());
+ for (ClassFileResourceProvider libraryResourceProvider :
+ command.getInputApp().getLibraryResourceProviders()) {
+ builder.addLibrary(libraryResourceProvider);
}
+ String jsonSource = command.getDesugaredLibraryConfiguration().getJsonSource();
+ if (jsonSource != null) {
+ builder.setDesugarLibrarySpecification(
+ StringResource.fromString(jsonSource, Origin.unknown()));
+ }
+ return builder
+ .setMinApi(command.getMinApiLevel())
+ .setOutputConsumer(command.getBackportedMethodListConsumer())
+ .build();
}
public static void run(String[] args) throws CompilationFailedException {