Use StrictJarManifest.ATTRIBUTE_NAME_NAME instead of Attributes.Name.NAME.
Introduce a constant StrictJarManifest.ATTRIBUTE_NAME_NAME so that
callers (StrictJarManifest{,Reader}) don't need to rely on
Attributes.Name.NAME which was added via an Android patch.
Bug: 35910877
Test: Treehugger
Change-Id: I292fbefc6c5561609dcd8281d1e2a931a1ffa5b2
diff --git a/core/java/android/util/jar/StrictJarManifest.java b/core/java/android/util/jar/StrictJarManifest.java
index dbb466c..faec099 100644
--- a/core/java/android/util/jar/StrictJarManifest.java
+++ b/core/java/android/util/jar/StrictJarManifest.java
@@ -44,6 +44,9 @@
private static final byte[] VALUE_SEPARATOR = new byte[] { ':', ' ' };
+ /** The attribute name "Name". */
+ static final Attributes.Name ATTRIBUTE_NAME_NAME = new Attributes.Name("Name");
+
private final Attributes mainAttributes;
private final HashMap<String, Attributes> entries;
@@ -276,7 +279,7 @@
Iterator<String> i = manifest.getEntries().keySet().iterator();
while (i.hasNext()) {
String key = i.next();
- writeEntry(out, Attributes.Name.NAME, key, encoder, buffer);
+ writeEntry(out, ATTRIBUTE_NAME_NAME, key, encoder, buffer);
Attributes attributes = manifest.entries.get(key);
Iterator<?> entries = attributes.keySet().iterator();
while (entries.hasNext()) {
diff --git a/core/java/android/util/jar/StrictJarManifestReader.java b/core/java/android/util/jar/StrictJarManifestReader.java
index 9881bb0..b17abc8 100644
--- a/core/java/android/util/jar/StrictJarManifestReader.java
+++ b/core/java/android/util/jar/StrictJarManifestReader.java
@@ -58,7 +58,7 @@
public void readEntries(Map<String, Attributes> entries, Map<String, StrictJarManifest.Chunk> chunks) throws IOException {
int mark = pos;
while (readHeader()) {
- if (!Attributes.Name.NAME.equals(name)) {
+ if (!StrictJarManifest.ATTRIBUTE_NAME_NAME.equals(name)) {
throw new IOException("Entry is not named");
}
String entryNameValue = value;