--
PiperOrigin-RevId: 148938713
MOS_MIGRATED_REVID=148938713
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
index 21722e9..1574af2 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
@@ -1559,10 +1559,12 @@
// Users can create this situation by directly depending on a .jar artifact (checked in
// or coming from a genrule or similar, b/11285003). This will also catch new implicit
// dependencies that incremental dexing would need to be extended to (b/34949364).
+ // Typically the fix for the latter involves propagating DexArchiveAspect along the
+ // attribute defining the new implicit dependency.
ruleContext.throwWithAttributeError("deps", "Dependencies on .jar artifacts are not "
+ "allowed in Android binaries, please use a java_import to depend on "
- + jar.prettyPrint() + ". If this is an implicit dependency then Bazel will need "
- + "to be fixed to account for it correctly.");
+ + jar.prettyPrint() + ". If this is an implicit dependency then the rule that "
+ + "introduces it will need to be fixed to account for it correctly.");
}
dexedClasspath.add(dexArchive != null ? dexArchive : jar);
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveProvider.java
index f045941..5b98128 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/DexArchiveProvider.java
@@ -26,7 +26,7 @@
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
@@ -114,8 +114,9 @@
* Returns a flat map from Jars to dex archives transitively produced for the given dexopts.
*/
public Map<Artifact, Artifact> archivesForDexopts(ImmutableSet<String> dexopts) {
- // Can't use ImmutableMap because we can encounter the same key-value pair multiple times
- HashMap<Artifact, Artifact> result = new HashMap<>();
+ // Can't use ImmutableMap because we can encounter the same key-value pair multiple times.
+ // Use LinkedHashMap in case someone tries to iterate this map (not the case as of 2/2017).
+ LinkedHashMap<Artifact, Artifact> result = new LinkedHashMap<>();
for (ImmutableTable<ImmutableSet<String>, Artifact, Artifact> partialMapping : dexArchives) {
result.putAll(partialMapping.row(dexopts));
}