8062194: java.util.jar.Attributes should use insertion-ordered iteration

S/HashMap/LinkedHashMap/g

Reviewed-by: alanb, sherman
This commit is contained in:
Martin Buchholz 2014-10-27 16:24:43 -07:00
parent 187bacb237
commit 72f7a2a671
2 changed files with 80 additions and 3 deletions

View file

@ -28,7 +28,7 @@ package java.util.jar;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.Collection;
@ -47,6 +47,9 @@ import sun.misc.ASCIICaseInsensitiveComparator;
* <a href="../../../../technotes/guides/jar/jar.html">JAR File Specification</a>
* for more information about valid attribute names and values.
*
* <p>This map and its views have a predictable iteration order, namely the
* order that keys were inserted into the map, as with {@link LinkedHashMap}.
*
* @author David Connelly
* @see Manifest
* @since 1.2
@ -71,7 +74,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
* @param size the initial number of attributes
*/
public Attributes(int size) {
map = new HashMap<>(size);
map = new LinkedHashMap<>(size);
}
/**
@ -81,7 +84,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
* @param attr the specified Attributes
*/
public Attributes(Attributes attr) {
map = new HashMap<>(attr);
map = new LinkedHashMap<>(attr);
}