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

* aosp/upstream-master: (25 commits)
  Track the origin of an option in the option instance, not its final value.
  Deprecate wrapperOptions.
  Track all option instances.
  Cleanup of expansion option naming
  Create multiple ParamsFilePreProcessors to allow parsing files using the formats specified in ParameterFile.ParameterFileType. Also maintain the currently used parsing style of whitespace split arguments that allows single and double quoting and whitespace and quote escaping. This style of parsing is for a format not currently generated and will be removed once all consuming actions have been converted to using a supported format explicitly.
  Document the options in smaller commands.
  Treat parsed option values differently by option type.
  Throw away the confusing UnparsedOptionValueDescription name.
  Introduce "bazel help flags-as-proto" to print information about supported flags as a text protobuf.
  Pass the UnparsedOptionValues when setting or adding option values.
  Consolidate the "unparsed" option value tracking.
  Open source tests for Android desugarer.
  Move option value tracking classes to their own file.
  Replace referrals to options by their name to option definitions.
  Option value tracking should refer to the option definitions, not just track option name.
  Options with oldNames will no longer get reported twice in the effective option lists.
  fix for legacy jacoco instrumentation in interfaces behind flag RELNOTES: n/a
  Expansion flags need some restraints.
  Rename all logger instances to "logger" (instead "LOG" or "log").
  Update comments about the option processor.
  ...

Test: mma external/desugar
Change-Id: I718bba35f1eb9eaacd68cb37d79a5c2068d3b9c1
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..39af2a6
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,35 @@
+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_BETA",
+        "asm-commons-6.0_BETA",
+        "asm-tree-6.0_BETA",
+        "error_prone_annotations-2.0.18",
+        "guava-21.0",
+        "jsr305-3.0.1",
+    ],
+
+    // 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/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 26d918b..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,221 +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/CoreLibraryRewriter.java b/java/com/google/devtools/build/android/desugar/CoreLibraryRewriter.java
index fd61702..cbb3271 100644
--- a/java/com/google/devtools/build/android/desugar/CoreLibraryRewriter.java
+++ b/java/com/google/devtools/build/android/desugar/CoreLibraryRewriter.java
@@ -133,7 +133,7 @@
     private final ClassWriter writer;
 
     UnprefixingClassWriter(int flags) {
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
       this.writer = new ClassWriter(flags);
       this.cv = this.writer;
       if (!prefix.isEmpty()) {
diff --git a/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java b/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java
index d7d46a1..9b20c9d 100644
--- a/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java
+++ b/java/com/google/devtools/build/android/desugar/DefaultMethodClassFixer.java
@@ -57,7 +57,7 @@
       ClassReaderFactory classpath,
       ClassReaderFactory bootclasspath,
       ClassLoader targetLoader) {
-    super(Opcodes.ASM5, dest);
+    super(Opcodes.ASM6, dest);
     this.classpath = classpath;
     this.bootclasspath = bootclasspath;
     this.targetLoader = targetLoader;
@@ -380,7 +380,7 @@
     private String interfaceName;
 
     public DefaultMethodStubber() {
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
     }
 
     @Override
@@ -457,7 +457,7 @@
     private boolean found;
 
     public DefaultMethodFinder() {
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
     }
 
     @Override
@@ -499,7 +499,7 @@
   private class InstanceMethodRecorder extends ClassVisitor {
 
     public InstanceMethodRecorder() {
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
     }
 
     @Override
@@ -535,7 +535,7 @@
     private boolean hasDefaultMethods;
 
     public InterfaceInitializationNecessityDetector(String internalName) {
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
       this.internalName = internalName;
     }
 
@@ -569,7 +569,7 @@
         hasDefaultMethods = isNonBridgeDefaultMethod(access);
       }
       if ("<clinit>".equals(name)) {
-        return new MethodVisitor(Opcodes.ASM5) {
+        return new MethodVisitor(Opcodes.ASM6) {
           @Override
           public void visitFieldInsn(int opcode, String owner, String name, String desc) {
             if (opcode == Opcodes.PUTSTATIC && internalName.equals(owner)) {
diff --git a/java/com/google/devtools/build/android/desugar/HeaderClassLoader.java b/java/com/google/devtools/build/android/desugar/HeaderClassLoader.java
index 5be41cf..0a757bf 100644
--- a/java/com/google/devtools/build/android/desugar/HeaderClassLoader.java
+++ b/java/com/google/devtools/build/android/desugar/HeaderClassLoader.java
@@ -86,7 +86,7 @@
     private String internalName;
 
     public NonPrimitiveFieldCollector() {
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
     }
 
     @Override
@@ -131,7 +131,7 @@
     private final ImmutableList<FieldInfo> interfaceFields;
 
     public CodeStubber(ClassVisitor cv, ImmutableList<FieldInfo> interfaceFields) {
-      super(Opcodes.ASM5, cv);
+      super(Opcodes.ASM6, cv);
       this.interfaceFields = interfaceFields;
     }
 
@@ -177,7 +177,7 @@
 
     public InterfaceInitializerEraser(
         MethodVisitor mv, String internalName, ImmutableList<FieldInfo> interfaceFields) {
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
       dest = mv;
       this.interfaceFields = interfaceFields;
     }
@@ -208,7 +208,7 @@
     private boolean hasCode = false;
 
     public BodyStubber(MethodVisitor mv) {
-      super(Opcodes.ASM5, mv);
+      super(Opcodes.ASM6, mv);
     }
 
     @Override
diff --git a/java/com/google/devtools/build/android/desugar/InterfaceDesugaring.java b/java/com/google/devtools/build/android/desugar/InterfaceDesugaring.java
index 6bac9ed..0d37a20 100644
--- a/java/com/google/devtools/build/android/desugar/InterfaceDesugaring.java
+++ b/java/com/google/devtools/build/android/desugar/InterfaceDesugaring.java
@@ -58,7 +58,7 @@
   public InterfaceDesugaring(
       ClassVisitor dest, ClassReaderFactory bootclasspath, GeneratedClassStore store,
       boolean legacyJaCoCo) {
-    super(Opcodes.ASM5, dest);
+    super(Opcodes.ASM6, dest);
     this.bootclasspath = bootclasspath;
     this.store = store;
     this.legacyJaCoCo = legacyJaCoCo;
@@ -279,7 +279,7 @@
   private class InterfaceFieldWriteCollector extends MethodVisitor {
 
     public InterfaceFieldWriteCollector(MethodVisitor mv) {
-      super(Opcodes.ASM5, mv);
+      super(Opcodes.ASM6, mv);
     }
 
     @Override
@@ -316,7 +316,7 @@
 
     public InterfaceInvocationRewriter(
         MethodVisitor dest, @Nullable String knownInterfaceName, ClassReaderFactory bootclasspath) {
-      super(Opcodes.ASM5, dest);
+      super(Opcodes.ASM6, dest);
       this.interfaceName = knownInterfaceName;
       this.bootclasspath = bootclasspath;
     }
@@ -400,7 +400,7 @@
     private final MethodVisitor annotationOnlyDest;
 
     public MultiplexAnnotations(@Nullable MethodVisitor dest, MethodVisitor annotationOnlyDest) {
-      super(Opcodes.ASM5, dest);
+      super(Opcodes.ASM6, dest);
       this.annotationOnlyDest = annotationOnlyDest;
     }
 
@@ -445,7 +445,7 @@
 
     public MultiplexAnnotationVisitor(
         @Nullable AnnotationVisitor dest, AnnotationVisitor... moreDestinations) {
-      super(Opcodes.ASM5, dest);
+      super(Opcodes.ASM6, dest);
       this.moreDestinations = moreDestinations;
     }
 
diff --git a/java/com/google/devtools/build/android/desugar/InvokeDynamicLambdaMethodCollector.java b/java/com/google/devtools/build/android/desugar/InvokeDynamicLambdaMethodCollector.java
index 5d26a0a..002c08b 100644
--- a/java/com/google/devtools/build/android/desugar/InvokeDynamicLambdaMethodCollector.java
+++ b/java/com/google/devtools/build/android/desugar/InvokeDynamicLambdaMethodCollector.java
@@ -32,7 +32,7 @@
   private boolean needOuterClassRewrite = false;
 
   public InvokeDynamicLambdaMethodCollector() {
-    super(Opcodes.ASM5);
+    super(Opcodes.ASM6);
   }
 
   /**
@@ -64,7 +64,7 @@
   private class LambdaMethodCollector extends MethodVisitor {
 
     public LambdaMethodCollector(MethodVisitor dest) {
-      super(Opcodes.ASM5, dest);
+      super(Opcodes.ASM6, dest);
     }
 
     @Override
diff --git a/java/com/google/devtools/build/android/desugar/Java7Compatibility.java b/java/com/google/devtools/build/android/desugar/Java7Compatibility.java
index fc4c75f..752227e 100644
--- a/java/com/google/devtools/build/android/desugar/Java7Compatibility.java
+++ b/java/com/google/devtools/build/android/desugar/Java7Compatibility.java
@@ -38,7 +38,7 @@
   private String internalName;
 
   public Java7Compatibility(ClassVisitor cv, ClassReaderFactory factory) {
-    super(Opcodes.ASM5, cv);
+    super(Opcodes.ASM6, cv);
     this.factory = factory;
   }
 
@@ -98,7 +98,7 @@
 
   private class InlineJacocoInit extends MethodVisitor {
     public InlineJacocoInit(MethodVisitor dest) {
-      super(Opcodes.ASM5, dest);
+      super(Opcodes.ASM6, dest);
     }
 
     @Override
@@ -123,7 +123,7 @@
     private int copied = 0;
 
     public InlineOneMethod(String methodName, MethodVisitor dest) {
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
       this.methodName = methodName;
       this.dest = dest;
     }
@@ -157,7 +157,7 @@
     public InlineMethodBody(MethodVisitor dest) {
       // We'll set the destination visitor in visitCode() to reduce the risk of copying anything
       // we didn't mean to copy
-      super(Opcodes.ASM5, (MethodVisitor) null);
+      super(Opcodes.ASM6, (MethodVisitor) null);
       this.dest = dest;
     }
 
diff --git a/java/com/google/devtools/build/android/desugar/LambdaClassFixer.java b/java/com/google/devtools/build/android/desugar/LambdaClassFixer.java
index 630559e..fb05bcb 100644
--- a/java/com/google/devtools/build/android/desugar/LambdaClassFixer.java
+++ b/java/com/google/devtools/build/android/desugar/LambdaClassFixer.java
@@ -71,7 +71,7 @@
       ImmutableSet<String> interfaceLambdaMethods,
       boolean allowDefaultMethods,
       boolean copyBridgeMethods) {
-    super(Opcodes.ASM5, dest);
+    super(Opcodes.ASM6, dest);
     checkArgument(!allowDefaultMethods || interfaceLambdaMethods.isEmpty());
     checkArgument(allowDefaultMethods || copyBridgeMethods);
     this.lambdaInfo = lambdaInfo;
@@ -240,7 +240,7 @@
   /** Rewriter for methods in generated lambda classes. */
   private class LambdaClassMethodRewriter extends MethodVisitor {
     public LambdaClassMethodRewriter(MethodVisitor dest) {
-      super(Opcodes.ASM5, dest);
+      super(Opcodes.ASM6, dest);
     }
 
     @Override
@@ -300,7 +300,7 @@
   private static class LambdaClassInvokeSpecialRewriter extends MethodVisitor {
 
     public LambdaClassInvokeSpecialRewriter(MethodVisitor dest) {
-      super(Opcodes.ASM5, dest);
+      super(Opcodes.ASM6, dest);
     }
 
     @Override
@@ -325,7 +325,7 @@
 
     public CopyBridgeMethods() {
       // No delegate visitor; instead we'll add methods to the outer class's delegate where needed
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
     }
 
     @Override
@@ -370,7 +370,7 @@
 
     public CopyOneMethod(String methodName) {
       // No delegate visitor; instead we'll add methods to the outer class's delegate where needed
-      super(Opcodes.ASM5);
+      super(Opcodes.ASM6);
       checkState(!allowDefaultMethods, "Couldn't copy interface lambda bodies");
       this.methodName = methodName;
     }
@@ -415,7 +415,7 @@
    */
   private static class AvoidJacocoInit extends MethodVisitor {
     public AvoidJacocoInit(MethodVisitor dest) {
-      super(Opcodes.ASM5, dest);
+      super(Opcodes.ASM6, dest);
     }
 
     @Override
@@ -444,7 +444,7 @@
         String desc,
         String signature,
         String[] exceptions) {
-      super(Opcodes.ASM5, access, name, desc, signature, exceptions);
+      super(Opcodes.ASM6, access, name, desc, signature, exceptions);
       this.dest = dest;
       this.lambdaInfo = lambdaInfo;
       this.classLoader = classLoader;
diff --git a/java/com/google/devtools/build/android/desugar/LambdaDesugaring.java b/java/com/google/devtools/build/android/desugar/LambdaDesugaring.java
index b1eefa8..652f025 100644
--- a/java/com/google/devtools/build/android/desugar/LambdaDesugaring.java
+++ b/java/com/google/devtools/build/android/desugar/LambdaDesugaring.java
@@ -17,7 +17,7 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 import static java.lang.invoke.MethodHandles.publicLookup;
-import static org.objectweb.asm.Opcodes.ASM5;
+import static org.objectweb.asm.Opcodes.ASM6;
 
 import com.google.auto.value.AutoValue;
 import com.google.common.collect.ImmutableSet;
@@ -73,7 +73,7 @@
       ImmutableSet.Builder<String> aggregateInterfaceLambdaMethods,
       ImmutableSet<MethodInfo> lambdaMethodsUsedInInvokeDyanmic,
       boolean allowDefaultMethods) {
-    super(Opcodes.ASM5, dest);
+    super(Opcodes.ASM6, dest);
     this.targetLoader = targetLoader;
     this.lambdas = lambdas;
     this.aggregateInterfaceLambdaMethods = aggregateInterfaceLambdaMethods;
@@ -381,7 +381,7 @@
         String desc,
         String signature,
         String[] exceptions) {
-      super(ASM5, access, name, desc, signature, exceptions);
+      super(ASM6, access, name, desc, signature, exceptions);
       this.dest = checkNotNull(dest, "Null destination for %s.%s : %s", internalName, name, desc);
     }
 
diff --git a/java/com/google/devtools/build/android/desugar/LongCompareMethodRewriter.java b/java/com/google/devtools/build/android/desugar/LongCompareMethodRewriter.java
index 23d7a0d..f66d862 100644
--- a/java/com/google/devtools/build/android/desugar/LongCompareMethodRewriter.java
+++ b/java/com/google/devtools/build/android/desugar/LongCompareMethodRewriter.java
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.android.desugar;
 
-import static org.objectweb.asm.Opcodes.ASM5;
+import static org.objectweb.asm.Opcodes.ASM6;
 import static org.objectweb.asm.Opcodes.INVOKESTATIC;
 import static org.objectweb.asm.Opcodes.LCMP;
 
@@ -27,7 +27,7 @@
 public class LongCompareMethodRewriter extends ClassVisitor {
 
   public LongCompareMethodRewriter(ClassVisitor cv) {
-    super(ASM5, cv);
+    super(ASM6, cv);
   }
 
   @Override
@@ -40,7 +40,7 @@
   private static class LongCompareMethodVisitor extends MethodVisitor {
 
     public LongCompareMethodVisitor(MethodVisitor visitor) {
-      super(ASM5, visitor);
+      super(ASM6, visitor);
     }
 
     @Override
diff --git a/java/com/google/devtools/build/android/desugar/ObjectsRequireNonNullMethodRewriter.java b/java/com/google/devtools/build/android/desugar/ObjectsRequireNonNullMethodRewriter.java
index 5ce0bee..86465d6 100644
--- a/java/com/google/devtools/build/android/desugar/ObjectsRequireNonNullMethodRewriter.java
+++ b/java/com/google/devtools/build/android/desugar/ObjectsRequireNonNullMethodRewriter.java
@@ -13,7 +13,7 @@
 // limitations under the License.
 package com.google.devtools.build.android.desugar;
 
-import static org.objectweb.asm.Opcodes.ASM5;
+import static org.objectweb.asm.Opcodes.ASM6;
 import static org.objectweb.asm.Opcodes.DUP;
 import static org.objectweb.asm.Opcodes.INVOKESTATIC;
 import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
@@ -30,7 +30,7 @@
 public class ObjectsRequireNonNullMethodRewriter extends ClassVisitor {
 
   public ObjectsRequireNonNullMethodRewriter(ClassVisitor cv) {
-    super(ASM5, cv);
+    super(ASM6, cv);
   }
 
   @Override
@@ -43,7 +43,7 @@
   private static class ObjectsMethodInlinerMethodVisitor extends MethodVisitor {
 
     public ObjectsMethodInlinerMethodVisitor(MethodVisitor mv) {
-      super(ASM5, mv);
+      super(ASM6, mv);
     }
 
     @Override
diff --git a/java/com/google/devtools/build/android/desugar/TryWithResourcesRewriter.java b/java/com/google/devtools/build/android/desugar/TryWithResourcesRewriter.java
index f7a3a7d..270d32b 100644
--- a/java/com/google/devtools/build/android/desugar/TryWithResourcesRewriter.java
+++ b/java/com/google/devtools/build/android/desugar/TryWithResourcesRewriter.java
@@ -16,7 +16,7 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.objectweb.asm.Opcodes.ACC_STATIC;
 import static org.objectweb.asm.Opcodes.ACC_SYNTHETIC;
-import static org.objectweb.asm.Opcodes.ASM5;
+import static org.objectweb.asm.Opcodes.ASM6;
 import static org.objectweb.asm.Opcodes.INVOKESTATIC;
 import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
 
@@ -109,7 +109,7 @@
       ClassLoader classLoader,
       Set<String> visitedExceptionTypes,
       AtomicInteger numOfTryWithResourcesInvoked) {
-    super(ASM5, classVisitor);
+    super(ASM6, classVisitor);
     this.classLoader = classLoader;
     this.visitedExceptionTypes = visitedExceptionTypes;
     this.numOfTryWithResourcesInvoked = numOfTryWithResourcesInvoked;
@@ -164,7 +164,7 @@
         String methodSignature,
         MethodVisitor methodVisitor,
         ClassLoader classLoader) {
-      super(ASM5, methodVisitor);
+      super(ASM6, methodVisitor);
       this.classLoader = classLoader;
       this.internalName = internalName;
       this.methodSignature = methodSignature;
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