Merge remote-tracking branch 'aosp/upstream-master' into master

* aosp/upstream-master:
  Automatic formatting cleanup of Android *.java files.
  Eagerly close directory content stream again when looking for dumped lambdas RELNOTES: None.
  reflect prefix in additional ClassReader methods for consistency with what happens during visit() RELNOTES: None.

Bug: 70415451
Test: m checkbuild
Change-Id: Ia4743853a34a9c0d315663959eac0dcd0fdb627b
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..f770906
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,37 @@
+java_library_host {
+    name: "desugar",
+    srcs: ["java/**/*.java"],
+    // Remove com.google.devtools.common.options.testing classes, they are
+    // extensions to the Truth library that we are missing dependencies for
+    // and don't need.
+    // Also remove com.google.devtools.common.options.InvocationPolicy*,
+    // which depend on protobuf and are not used in desugar.
+    exclude_srcs: [
+        "java/com/google/devtools/common/options/testing/**/*.java",
+        "java/com/google/devtools/common/options/InvocationPolicyEnforcer.java",
+        "java/com/google/devtools/common/options/InvocationPolicyParser.java",
+    ],
+
+    manifest: "manifest.txt",
+    static_libs: [
+        "asm-6.0",
+        "asm-commons-6.0",
+        "asm-tree-6.0",
+        "error_prone_annotations-2.0.18",
+        "guava-21.0",
+        "jsr305-3.0.1",
+    ],
+
+    openjdk9: {
+        // Required for use of javax.annotation.Generated per http://b/62050818
+        javacflags: ["-J--add-modules=java.xml.ws.annotation"],
+    },
+
+    // Use Dagger2 annotation processor
+    annotation_processors: ["dagger2-auto-value-host"],
+    libs: ["dagger2-auto-value-host"],
+    // b/25860419: annotation processors must be explicitly specified for grok
+    annotation_processor_classes: [
+        "com.google.auto.value.processor.AutoValueProcessor",
+    ],
+}
diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MODULE_LICENSE_APACHE2
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..a67e611
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,2 @@
+ccross@android.com
+gavra@google.com
diff --git a/copy.bara.sky b/copy.bara.sky
new file mode 100644
index 0000000..714e46f
--- /dev/null
+++ b/copy.bara.sky
@@ -0,0 +1,40 @@
+# Copybara project config for importing desugar tool from bazel
+import_url = "rpc://github.googlesource.com/bazelbuild/bazel"
+
+core.workflow(
+    name = "default",
+    origin = git.origin(
+        url = import_url,
+        ref = "master",
+    ),
+    origin_files = glob(
+        include = [
+            "src/tools/android/java/com/google/devtools/build/android/desugar/**",
+            "src/test/java/com/google/devtools/build/android/desugar/**",
+            "src/tools/android/java/com/google/devtools/build/android/Converters.java",
+            "src/main/java/com/google/devtools/common/options/**",
+        ],
+        exclude = [
+            "**/BUILD*",
+        ],
+    ),
+    destination = git.gerrit_destination(
+        url = "sso://android/platform/external/desugar",
+        fetch = "upstream-master",
+        push_to_refs_for = "upstream-master",
+    ),
+    authoring = authoring.pass_thru("Bazel Team <no-reply@google.com>"),
+    mode = "ITERATIVE",
+    transformations = [
+        core.verify_match(
+            regex = "Licensed under the Apache License, Version 2.0",
+            paths = glob(["**"], exclude = [
+                "src/test/java/com/google/devtools/build/android/desugar/**.txt",
+                "src/test/java/com/google/devtools/build/android/desugar/**.jar"
+                ]),
+        ),
+        core.move("src/tools/android", ""),
+        core.move("src/main", ""),
+        core.move("src/test/", "test"),
+    ],
+)
diff --git a/java/com/google/devtools/build/android/Converters.java b/java/com/google/devtools/build/android/Converters.java
index e58dd2d..c4d9b2d 100644
--- a/java/com/google/devtools/build/android/Converters.java
+++ b/java/com/google/devtools/build/android/Converters.java
@@ -13,34 +13,12 @@
 // limitations under the License.
 package com.google.devtools.build.android;
 
-import com.android.builder.core.VariantType;
-import com.android.manifmerger.ManifestMerger2;
-import com.android.manifmerger.ManifestMerger2.MergeType;
-import com.android.repository.Revision;
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.devtools.build.android.aapt2.CompiledResources;
-import com.google.devtools.build.android.aapt2.StaticLibrary;
 import com.google.devtools.common.options.Converter;
-import com.google.devtools.common.options.EnumConverter;
 import com.google.devtools.common.options.OptionsParsingException;
-import java.io.File;
-import java.lang.reflect.ParameterizedType;
 import java.nio.file.FileSystems;
 import java.nio.file.Files;
 import java.nio.file.InvalidPathException;
 import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import javax.annotation.Nullable;
 
 /**
  * Some convenient converters used by android actions. Note: These are specific to android actions.
@@ -59,209 +37,6 @@
         }
       };
 
-  /**
-   * Converter for {@link UnvalidatedAndroidData}. Relies on {@code
-   * UnvalidatedAndroidData#valueOf(String)} to perform conversion and validation.
-   */
-  public static class UnvalidatedAndroidDataConverter implements Converter<UnvalidatedAndroidData> {
-
-    @Override
-    public UnvalidatedAndroidData convert(String input) throws OptionsParsingException {
-      try {
-        return UnvalidatedAndroidData.valueOf(input);
-      } catch (IllegalArgumentException e) {
-        throw new OptionsParsingException(
-            String.format("invalid UnvalidatedAndroidData: %s", e.getMessage()), e);
-      }
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "unvalidated android data in the format " + UnvalidatedAndroidData.EXPECTED_FORMAT;
-    }
-  }
-
-  /** Converter for {@link UnvalidatedAndroidDirectories}. */
-  public static class UnvalidatedAndroidDirectoriesConverter
-      implements Converter<UnvalidatedAndroidDirectories> {
-
-    @Override
-    public UnvalidatedAndroidDirectories convert(String input) throws OptionsParsingException {
-      try {
-        return UnvalidatedAndroidDirectories.valueOf(input);
-      } catch (IllegalArgumentException e) {
-        throw new OptionsParsingException(
-            String.format("invalid UnvalidatedAndroidDirectories: %s", e.getMessage()), e);
-      }
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "unvalidated android directories in the format "
-          + UnvalidatedAndroidDirectories.EXPECTED_FORMAT;
-    }
-  }
-
-  /**
-   * Converter for a list of {@link DependencyAndroidData}. Relies on {@code
-   * DependencyAndroidData#valueOf(String)} to perform conversion and validation.
-   */
-  public static class DependencyAndroidDataListConverter
-      implements Converter<List<DependencyAndroidData>> {
-
-    @Override
-    public List<DependencyAndroidData> convert(String input) throws OptionsParsingException {
-      if (input.isEmpty()) {
-        return ImmutableList.of();
-      }
-      try {
-        ImmutableList.Builder<DependencyAndroidData> builder = ImmutableList.builder();
-        for (String item : input.split(",")) {
-          builder.add(DependencyAndroidData.valueOf(item));
-        }
-        return builder.build();
-      } catch (IllegalArgumentException e) {
-        throw new OptionsParsingException(
-            String.format("invalid DependencyAndroidData: %s", e.getMessage()), e);
-      }
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "a list of dependency android data in the format "
-          + DependencyAndroidData.EXPECTED_FORMAT
-          + "[,...]";
-    }
-  }
-
-  /** Converter for a {@link SerializedAndroidData}. */
-  public static class SerializedAndroidDataConverter implements Converter<SerializedAndroidData> {
-
-    @Override
-    public SerializedAndroidData convert(String input) throws OptionsParsingException {
-      try {
-        return SerializedAndroidData.valueOf(input);
-      } catch (IllegalArgumentException e) {
-        throw new OptionsParsingException(
-            String.format("invalid SerializedAndroidData: %s", e.getMessage()), e);
-      }
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "preparsed android data in the format " + SerializedAndroidData.EXPECTED_FORMAT;
-    }
-  }
-
-  /** Converter for a list of {@link SerializedAndroidData}. */
-  public static class SerializedAndroidDataListConverter
-      implements Converter<List<SerializedAndroidData>> {
-
-    @Override
-    public List<SerializedAndroidData> convert(String input) throws OptionsParsingException {
-      if (input.isEmpty()) {
-        return ImmutableList.of();
-      }
-      try {
-        ImmutableList.Builder<SerializedAndroidData> builder = ImmutableList.builder();
-        for (String entry : input.split("&")) {
-          builder.add(SerializedAndroidData.valueOf(entry));
-        }
-        return builder.build();
-      } catch (IllegalArgumentException e) {
-        throw new OptionsParsingException(
-            String.format("invalid SerializedAndroidData: %s", e.getMessage()), e);
-      }
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "a list of preparsed android data in the format "
-          + SerializedAndroidData.EXPECTED_FORMAT
-          + "[&...]";
-    }
-  }
-
-  /** Converter for a single {@link DependencySymbolFileProvider}. */
-  public static class DependencySymbolFileProviderConverter
-      implements Converter<DependencySymbolFileProvider> {
-
-    @Override
-    public DependencySymbolFileProvider convert(String input) throws OptionsParsingException {
-      try {
-        return DependencySymbolFileProvider.valueOf(input);
-      } catch (IllegalArgumentException e) {
-        throw new OptionsParsingException(
-            String.format("invalid DependencyAndroidData: %s", e.getMessage()), e);
-      }
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return String.format(
-          "a dependency android data in the format: %s[%s]",
-          DependencySymbolFileProvider.commandlineFormat("1"),
-          DependencySymbolFileProvider.commandlineFormat("2"));
-    }
-  }
-
-  /**
-   * Converter for a list of {@link DependencySymbolFileProvider}. Relies on {@code
-   * DependencySymbolFileProvider#valueOf(String)} to perform conversion and validation.
-   *
-   * @deprecated use multi-value flags and {@link DependencySymbolFileProviderConverter} instead.
-   */
-  @Deprecated
-  public static class DependencySymbolFileProviderListConverter
-      implements Converter<List<DependencySymbolFileProvider>> {
-
-    @Override
-    public List<DependencySymbolFileProvider> convert(String input) throws OptionsParsingException {
-      if (input.isEmpty()) {
-        return ImmutableList.<DependencySymbolFileProvider>of();
-      }
-      try {
-        ImmutableList.Builder<DependencySymbolFileProvider> builder = ImmutableList.builder();
-        for (String item : input.split(",")) {
-          builder.add(DependencySymbolFileProvider.valueOf(item));
-        }
-        return builder.build();
-      } catch (IllegalArgumentException e) {
-        throw new OptionsParsingException(
-            String.format("invalid DependencyAndroidData: %s", e.getMessage()), e);
-      }
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return String.format(
-          "a list of dependency android data in the format: %s[%s]",
-          DependencySymbolFileProvider.commandlineFormat("1"),
-          DependencySymbolFileProvider.commandlineFormat("2"));
-    }
-  }
-
-  /**
-   * Converter for {@link Revision}. Relies on {@code Revision#parseRevision(String)} to perform
-   * conversion and validation.
-   */
-  public static class RevisionConverter implements Converter<Revision> {
-
-    @Override
-    public Revision convert(String input) throws OptionsParsingException {
-      try {
-        return Revision.parseRevision(input);
-      } catch (NumberFormatException e) {
-        throw new OptionsParsingException(e.getMessage());
-      }
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "a revision number";
-    }
-  }
-
   /** Validating converter for Paths. A Path is considered valid if it resolves to a file. */
   public static class PathConverter implements Converter<Path> {
 
@@ -304,223 +79,4 @@
       super(true);
     }
   }
-
-  /** Converter for {@link VariantType}. */
-  public static class VariantTypeConverter extends EnumConverter<VariantType> {
-    public VariantTypeConverter() {
-      super(VariantType.class, "variant type");
-    }
-  }
-
-  /** Converter for {@link ManifestMerger2}.{@link MergeType}. */
-  public static class MergeTypeConverter extends EnumConverter<MergeType> {
-    public MergeTypeConverter() {
-      super(MergeType.class, "merge type");
-    }
-  }
-
-  public static <T> List<T> concatLists(
-      @Nullable List<? extends T> a, @Nullable List<? extends T> b) {
-    @SuppressWarnings("unchecked")
-    List<T> la = (List<T>) a;
-    @SuppressWarnings("unchecked")
-    List<T> lb = (List<T>) b;
-    if (la == null || la.isEmpty()) {
-      return (lb == null || lb.isEmpty()) ? ImmutableList.of() : lb;
-    }
-    return (lb == null || lb.isEmpty()) ? la : ImmutableList.copyOf(Iterables.concat(la, lb));
-  }
-
-  /**
-   * Validating converter for a list of Paths. A Path is considered valid if it resolves to a file.
-   */
-  @Deprecated
-  public static class PathListConverter implements Converter<List<Path>> {
-
-    private final PathConverter baseConverter;
-
-    public PathListConverter() {
-      this(false);
-    }
-
-    protected PathListConverter(boolean mustExist) {
-      baseConverter = new PathConverter(mustExist);
-    }
-
-    @Override
-    public List<Path> convert(String input) throws OptionsParsingException {
-      List<Path> list = new ArrayList<>();
-      for (String piece : input.split(":")) {
-        if (!piece.isEmpty()) {
-          list.add(baseConverter.convert(piece));
-        }
-      }
-      return Collections.unmodifiableList(list);
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "a colon-separated list of paths";
-    }
-  }
-
-  // Commas that are not escaped by a backslash.
-  private static final String UNESCAPED_COMMA_REGEX = "(?<!\\\\)\\,";
-  // Colons that are not escaped by a backslash.
-  private static final String UNESCAPED_COLON_REGEX = "(?<!\\\\)\\:";
-
-  private static String unescapeInput(String input) {
-    return input.replace("\\:", ":").replace("\\,", ",");
-  }
-
-  /**
-   * A converter for dictionary arguments of the format key:value[,key:value]*. The keys and values
-   * may contain colons and commas as long as they are escaped with a backslash.
-   */
-  private abstract static class DictionaryConverter<K, V> implements Converter<Map<K, V>> {
-    private final Converter<K> keyConverter;
-    private final Converter<V> valueConverter;
-
-    public DictionaryConverter(Converter<K> keyConverter, Converter<V> valueConverter) {
-      this.keyConverter = keyConverter;
-      this.valueConverter = valueConverter;
-    }
-
-    @Override
-    public Map<K, V> convert(String input) throws OptionsParsingException {
-      if (input.isEmpty()) {
-        return ImmutableMap.of();
-      }
-      Map<K, V> map = new LinkedHashMap<>();
-      // Only split on comma and colon that are not escaped with a backslash
-      for (String entry : input.split(UNESCAPED_COMMA_REGEX)) {
-        String[] entryFields = entry.split(UNESCAPED_COLON_REGEX, -1);
-        if (entryFields.length < 2) {
-          throw new OptionsParsingException(
-              String.format(
-                  "Dictionary entry [%s] does not contain both a key and a value.", entry));
-        } else if (entryFields.length > 2) {
-          throw new OptionsParsingException(
-              String.format("Dictionary entry [%s] contains too many fields.", entry));
-        }
-        // Unescape any comma or colon that is not a key or value separator.
-        String keyString = unescapeInput(entryFields[0]);
-        K key = keyConverter.convert(keyString);
-        if (map.containsKey(key)) {
-          throw new OptionsParsingException(
-              String.format("Dictionary already contains the key [%s].", keyString));
-        }
-        // Unescape any comma or colon that is not a key or value separator.
-        String valueString = unescapeInput(entryFields[1]);
-        V value = valueConverter.convert(valueString);
-        map.put(key, value);
-      }
-      return ImmutableMap.copyOf(map);
-    }
-
-    @Override
-    public String getTypeDescription() {
-      // Retrieve types of dictionary through reflection to avoid overriding this method in each
-      // subclass or passing types to this superclass.
-      return String.format(
-          "a comma-separated list of colon-separated key value pairs of the types %s and %s",
-          ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0],
-          ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[1]);
-    }
-  }
-
-  /**
-   * A converter for dictionary arguments of the format key:value[,key:value]*. The keys and values
-   * may contain colons and commas as long as they are escaped with a backslash. The key and value
-   * types are both String.
-   */
-  public static class StringDictionaryConverter extends DictionaryConverter<String, String> {
-    public StringDictionaryConverter() {
-      super(IDENTITY_CONVERTER, IDENTITY_CONVERTER);
-    }
-    // The way {@link OptionsData} checks for generic types requires convert to have literal type
-    // parameters and not argument type parameters.
-    @Override
-    public Map<String, String> convert(String input) throws OptionsParsingException {
-      return super.convert(input);
-    }
-  }
-
-  /**
-   * A converter for dictionary arguments of the format key:value[,key:value]*. The keys and values
-   * may contain colons and commas as long as they are escaped with a backslash. The key type is
-   * Path and the value type is String.
-   */
-  public static class ExistingPathStringDictionaryConverter
-      extends DictionaryConverter<Path, String> {
-    public ExistingPathStringDictionaryConverter() {
-      super(new ExistingPathConverter(), IDENTITY_CONVERTER);
-    }
-    // The way {@link OptionsData} checks for generic types requires convert to have literal type
-    // parameters and not argument type parameters.
-    @Override
-    public Map<Path, String> convert(String input) throws OptionsParsingException {
-      return super.convert(input);
-    }
-  }
-
-  /** Converts a list of static library strings into paths. */
-  @Deprecated
-  public static class StaticLibraryListConverter implements Converter<List<StaticLibrary>> {
-    static final Splitter SPLITTER = Splitter.on(File.pathSeparatorChar);
-
-    static final StaticLibraryConverter libraryConverter = new StaticLibraryConverter();
-
-    @Override
-    public List<StaticLibrary> convert(String input) throws OptionsParsingException {
-      final Builder<StaticLibrary> builder = ImmutableList.<StaticLibrary>builder();
-      for (String path : SPLITTER.splitToList(input)) {
-        builder.add(libraryConverter.convert(path));
-      }
-      return builder.build();
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "Static resource libraries.";
-    }
-  }
-
-  /** Converts a static library string into path. */
-  public static class StaticLibraryConverter implements Converter<StaticLibrary> {
-
-    static final PathConverter pathConverter = new PathConverter(true);
-
-    @Override
-    public StaticLibrary convert(String input) throws OptionsParsingException {
-      return StaticLibrary.from(pathConverter.convert(input));
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "Static resource library.";
-    }
-  }
-
-  /** Converts a string of resources and manifest into paths. */
-  public static class CompiledResourcesConverter implements Converter<CompiledResources> {
-    static final PathConverter pathConverter = new PathConverter(true);
-    static final Pattern COMPILED_RESOURCE_FORMAT = Pattern.compile("(.+):(.+)");
-
-    @Override
-    public CompiledResources convert(String input) throws OptionsParsingException {
-      final Matcher matched = COMPILED_RESOURCE_FORMAT.matcher(input);
-      if (!matched.find()) {
-        throw new OptionsParsingException("Expected format <resources zip>:<manifest>");
-      }
-      Path resources = pathConverter.convert(matched.group(1));
-      Path manifest = pathConverter.convert(matched.group(2));
-      return CompiledResources.from(resources, manifest);
-    }
-
-    @Override
-    public String getTypeDescription() {
-      return "Compiled resources zip.";
-    }
-  }
 }
diff --git a/java/com/google/devtools/build/android/desugar/dependencies/MetadataCollector.java b/java/com/google/devtools/build/android/desugar/dependencies/MetadataCollector.java
deleted file mode 100644
index 732ef50..0000000
--- a/java/com/google/devtools/build/android/desugar/dependencies/MetadataCollector.java
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2017 The Bazel Authors. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//    http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.google.devtools.build.android.desugar.dependencies;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-
-import com.google.devtools.build.android.desugar.DependencyCollector;
-import com.google.devtools.build.android.desugar.proto.DesugarDeps;
-import com.google.devtools.build.android.desugar.proto.DesugarDeps.Dependency;
-import com.google.devtools.build.android.desugar.proto.DesugarDeps.DesugarDepsInfo;
-import com.google.devtools.build.android.desugar.proto.DesugarDeps.InterfaceDetails;
-import com.google.devtools.build.android.desugar.proto.DesugarDeps.InterfaceWithCompanion;
-import com.google.devtools.build.android.desugar.proto.DesugarDeps.Type;
-import javax.annotation.Nullable;
-
-/** Dependency collector that emits collected metadata as a {@link DesugarDepsInfo} proto. */
-public final class MetadataCollector implements DependencyCollector {
-
-  private final boolean tolerateMissingDeps;
-  private final DesugarDepsInfo.Builder info = DesugarDeps.DesugarDepsInfo.newBuilder();
-
-  public MetadataCollector(boolean tolerateMissingDeps) {
-    this.tolerateMissingDeps = tolerateMissingDeps;
-  }
-
-  @Override
-  public void assumeCompanionClass(String origin, String target) {
-    checkArgument(target.endsWith(INTERFACE_COMPANION_SUFFIX),
-        "target not a companion: %s -> %s", origin, target);
-    info.addAssumePresent(
-        Dependency.newBuilder().setOrigin(wrapType(origin)).setTarget(wrapType(target)));
-  }
-
-  @Override
-  public void missingImplementedInterface(String origin, String target) {
-    checkArgument(!target.endsWith(INTERFACE_COMPANION_SUFFIX),
-        "target seems to be a companion: %s -> %s", origin, target);
-    checkState(tolerateMissingDeps,
-        "Couldn't find interface %s on the classpath for desugaring %s", target, origin);
-    info.addMissingInterface(
-        Dependency.newBuilder().setOrigin(wrapType(origin)).setTarget(wrapType(target)));
-  }
-
-  @Override
-  public void recordExtendedInterfaces(String origin, String... targets) {
-    if (targets.length > 0) {
-      InterfaceDetails.Builder details =
-          InterfaceDetails.newBuilder().setOrigin(wrapType(origin));
-      for (String target : targets) {
-        details.addExtendedInterface(wrapType(target));
-      }
-      info.addInterfaceWithSupertypes(details);
-    }
-  }
-
-  @Override
-  public void recordDefaultMethods(String origin, int count) {
-    checkArgument(!origin.endsWith(INTERFACE_COMPANION_SUFFIX),
-        "seems to be a companion: %s", origin);
-    info.addInterfaceWithCompanion(
-        InterfaceWithCompanion.newBuilder()
-            .setOrigin(wrapType(origin))
-            .setNumDefaultMethods(count));
-  }
-
-  @Override
-  @Nullable
-  public byte[] toByteArray() {
-    DesugarDepsInfo result = info.build();
-    return DesugarDepsInfo.getDefaultInstance().equals(result) ? null : result.toByteArray();
-  }
-
-  private static Type wrapType(String internalName) {
-    return Type.newBuilder().setBinaryName(internalName).build();
-  }
-}
\ No newline at end of file
diff --git a/manifest.txt b/manifest.txt
new file mode 100644
index 0000000..ab00503
--- /dev/null
+++ b/manifest.txt
@@ -0,0 +1 @@
+Main-Class: com.google.devtools.build.android.desugar.Desugar