JDK-4881740 : retrofit collection classes to use generics
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_8
  • CPU: generic
  • Submitted: 2003-06-20
  • Updated: 2021-03-03
  • Resolved: 2003-08-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Related Reports
Relates :  
Relates :  
Description
Please retrofit the collection classes to use generics.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b14
14-06-2004

SUGGESTED FIX s IdentityHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>, java.io.Serializable, Cloneable { public IdentityHashMap(); public IdentityHashMap(int expectedMaxSize); public IdentityHashMap(Map<? extends K, ? extends V> m); public int size(); public boolean isEmpty(); public V get(Object key); public boolean containsKey(Object key); public boolean containsValue(Object value); public V put(K key, V value); public void putAll(Map<? extends K, ? extends V> t); public V remove(Object key); public void clear(); public boolean equals(Object o); public int hashCode(); public Object clone(); public Set<K> keySet(); public Collection<V> values(); public Set<Map.Entry<K, V>> entrySet(); } ==================== java/util/Arrays.java ==================== package java.util; import java.lang.reflect.*; public class Arrays { private Arrays(); public static void sort(long[] a); public static void sort(long[] a, int fromIndex, int toIndex); public static void sort(int[] a); public static void sort(int[] a, int fromIndex, int toIndex); public static void sort(short[] a); public static void sort(short[] a, int fromIndex, int toIndex); public static void sort(char[] a); public static void sort(char[] a, int fromIndex, int toIndex); public static void sort(byte[] a); public static void sort(byte[] a, int fromIndex, int toIndex); public static void sort(double[] a); public static void sort(double[] a, int fromIndex, int toIndex); public static void sort(float[] a); public static void sort(float[] a, int fromIndex, int toIndex); public static void sort(Object[] a); public static void sort(Object[] a, int fromIndex, int toIndex); public static <T>void sort(T[] a, Comparator<? super T> c); public static <T>void sort(T[] a, int fromIndex, int toIndex, Comparator<? super T> c); public static int binarySearch(long[] a, long key); public static int binarySearch(int[] a, int key); public static int binarySearch(short[] a, short key); public static int binarySearch(char[] a, char key); public static int binarySearch(byte[] a, byte key); public static int binarySearch(double[] a, double key); public static int binarySearch(float[] a, float key); public static int binarySearch(Object[] a, Object key); public static <T>int binarySearch(T[] a, T key, Comparator<? super T> c); public static boolean equals(long[] a, long[] a2); public static boolean equals(int[] a, int[] a2); public static boolean equals(short[] a, short[] a2); public static boolean equals(char[] a, char[] a2); public static boolean equals(byte[] a, byte[] a2); public static boolean equals(boolean[] a, boolean[] a2); public static boolean equals(double[] a, double[] a2); public static boolean equals(float[] a, float[] a2); public static boolean equals(Object[] a, Object[] a2); public static void fill(long[] a, long val); public static void fill(long[] a, int fromIndex, int toIndex, long val); public static void fill(int[] a, int val); public static void fill(int[] a, int fromIndex, int toIndex, int val); public static void fill(short[] a, short val); public static void fill(short[] a, int fromIndex, int toIndex, short val); public static void fill(char[] a, char val); public static void fill(char[] a, int fromIndex, int toIndex, char val); public static void fill(byte[] a, byte val); public static void fill(byte[] a, int fromIndex, int toIndex, byte val); public static void fill(boolean[] a, boolean val); public static void fill(boolean[] a, int fromIndex, int toIndex, boolean val); public static void fill(double[] a, double val); public static void fill(double[] a, int fromIndex, int toIndex, double val); public static void fill(float[] a, float val); public static void fill(float[] a, int fromIndex, int toIndex, float val); public static void fill(Object[] a, Object val); public static void fill(Object[] a, int fromIndex, int toIndex, Object val); public static <T>List<T> asList(T[] a); } ==================== java/util/Collections.java ==================== package java.util; public class Collections { private Collections(); public static <T extends Comparable<? super T>>void sort(List<T> list); public static <T>void sort(List<T> list, Comparator<? super T> c); public static <T extends Object & Comparable<? super T>>int binarySearch(List<? extends T> list, T key); public static <T>int binarySearch(List<? extends T> list, T key, Comparator<? super T> c); public static void reverse(List<?> list); public static void shuffle(List<?> list); public static void shuffle(List<?> list, Random rnd); public static void swap(List<?> list, int i, int j); public static <T>void fill(List<? super T> list, T obj); public static <T>void copy(List<? super T> dest, List<? extends T> src); public static <T extends Object & Comparable<? super T>>T min(Collection<? extends T> coll); public static <T>T min(Collection<? extends T> coll, Comparator<? super T> comp); public static <T extends Object & Comparable<? super T>>T max(Collection<? extends T> coll); public static <T>T max(Collection<? extends T> coll, Comparator<? super T> comp); public static void rotate(List<?> list, int distance); public static <T>boolean replaceAll(List<T> list, T oldVal, T newVal); public static int indexOfSubList(List<?> source, List<?> target); public static int lastIndexOfSubList(List<?> source, List<?> target); public static <T>Collection<T> unmodifiableCollection(Collection<? extends T> c); public static <T>Set<T> unmodifiableSet(Set<? extends T> s); public static <T>SortedSet<T> unmodifiableSortedSet(SortedSet<T> s); public static <T>List<T> unmodifiableList(List<? extends T> list); public static <K, V>Map<K, V> unmodifiableMap(Map<? extends K, ? extends V> m); public static <K, V>SortedMap<K, V> unmodifiableSortedMap(SortedMap<K, ? extends V> m); public static <T>Collection<T> synchronizedCollection(Collection<T> c); public static <T>Set<T> synchronizedSet(Set<T> s); public static <T>SortedSet<T> synchronizedSortedSet(SortedSet<T> s); public static <T>List<T> synchronizedList(List<T> list); public static <K, V>Map<K, V> synchronizedMap(Map<K, V> m); public static <K, V>SortedMap<K, V> synchronizedSortedMap(SortedMap<K, V> m); public static final Set EMPTY_SET; public static final <T>Set<T> emptySet(); public static final List EMPTY_LIST; public static final <T>List<T> emptyList(); public static final Map EMPTY_MAP; public static final <K, V>Map<K, V> emptyMap(); public static <T>Set<T> singleton(T o); public static <T>List<T> singletonList(T o); public static <K, V>Map<K, V> singletonMap(K key, V value); public static <T>List<T> nCopies(int n, T o); public static <T extends Comparable<? super T>>Comparator<T> reverseOrder(); public static <T>Enumeration<T> enumeration(Collection<T> c); public static <T>ArrayList<T> list(Enumeration<T> e); } ==================== java/util/SortedSet.java ==================== package java.util; public interface SortedSet<E> extends Set<E> { Comparator<? super E> comparator(); SortedSet<E> subSet(E fromElement, E toElement); SortedSet<E> headSet(E toElement); SortedSet<E> tailSet(E fromElement); E first(); E last(); } ==================== java/util/SortedMap.java ==================== package java.util; public interface SortedMap<K, V> extends Map<K, V> { Comparator<? super K> comparator(); SortedMap<K, V> subMap(K fromKey, K toKey); SortedMap<K, V> headMap(K toKey); SortedMap<K, V> tailMap(K fromKey); K firstKey(); K lastKey(); } ==================== java/util/LinkedHashMap.java ==================== package java.util; import java.io.*; public class LinkedHashMap<K, V> extends HashMap<K, V> implements Map<K, V> { public LinkedHashMap(int initialCapacity, float loadFactor); public LinkedHashMap(int initialCapacity); public LinkedHashMap(); public LinkedHashMap(Map<? extends K, ? extends V> m); public LinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder); public boolean containsValue(Object value); public V get(Object key); public void clear(); protected boolean removeEldestEntry(Map.Entry<K, V> eldest); } ==================== java/util/TreeMap.java ==================== package java.util; public class TreeMap<K, V> extends AbstractMap<K, V> implements SortedMap<K, V>, Cloneable, java.io.Serializable { public TreeMap(); public TreeMap(Comparator<? super K> c); public TreeMap(Map<? extends K, ? extends V> m); public TreeMap(SortedMap<K, ? extends V> m); public int size(); public boolean containsKey(Object key); public boolean containsValue(Object value); public V get(Object key); public Comparator<? super K> comparator(); public K firstKey(); public K lastKey(); public void putAll(Map<? extends K, ? extends V> map); public V put(K key, V value); public V remove(Object key); public void clear(); public Object clone(); public Set<K> keySet(); public Collection<V> values(); public Set<Map.Entry<K, V>> entrySet(); public SortedMap<K, V> subMap(K fromKey, K toKey); public SortedMap<K, V> headMap(K toKey); public SortedMap<K, V> tailMap(K fromKey); } ==================== java/util/TreeSet.java ==================== package java.util; public class TreeSet<E> extends AbstractSet<E> implements SortedSet<E>, Cloneable, java.io.Serializable { private TreeSet(SortedMap<E, Object> m); public TreeSet(); public TreeSet(Comparator<? super E> c); public TreeSet(Collection<? extends E> c); public TreeSet(SortedSet<E> s); public Iterator<E> iterator(); public int size(); public boolean isEmpty(); public boolean contains(Object o); public boolean add(E o); public boolean remove(Object o); public void clear(); public boolean addAll(Collection<? extends E> c); public SortedSet<E> subSet(E fromElement, E toElement); public SortedSet<E> headSet(E toElement); public SortedSet<E> tailSet(E fromElement); public Comparator<? super E> comparator(); public E first(); public E last(); public Object clone(); } ==================== java/util/WeakHashMap.java ==================== package java.util; public class WeakHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V> { public WeakHashMap(int initialCapacity, float loadFactor); public WeakHashMap(int initialCapacity); public WeakHashMap(); public WeakHashMap(Map<? extends K, ? extends V> t); public int size(); public boolean isEmpty(); public V get(Object key); public boolean containsKey(Object key); public V put(K key, V value); public void putAll(Map<? extends K, ? extends V> m); public V remove(Object key); public void clear(); public boolean containsValue(Object value); public Set<K> keySet(); public Collection<V> values(); public Set<Map.Entry<K, V>> entrySet(); }
11-06-2004

SUGGESTED FIX ==================== java/util/ArrayList.java ==================== package java.util; public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable { public ArrayList(int initialCapacity); public ArrayList(); public ArrayList(Collection<? extends E> c); public void trimToSize(); public void ensureCapacity(int minCapacity); public int size(); public boolean isEmpty(); public boolean contains(Object elem); public int indexOf(Object elem); public int lastIndexOf(Object elem); public Object clone(); public Object[] toArray(); public <T>T[] toArray(T[] a); public E get(int index); public E set(int index, E element); public boolean add(E o); public void add(int index, E element); public E remove(int index); public boolean remove(Object o); public void clear(); public boolean addAll(Collection<? extends E> c); public boolean addAll(int index, Collection<? extends E> c); protected void removeRange(int fromIndex, int toIndex); } ==================== java/util/AbstractList.java ==================== package java.util; public abstract class AbstractList<E> extends AbstractCollection<E> implements List<E> { protected AbstractList(); public boolean add(E o); public abstract E get(int index); public E set(int index, E element); public void add(int index, E element); public E remove(int index); public int indexOf(Object o); public int lastIndexOf(Object o); public void clear(); public boolean addAll(int index, Collection<? extends E> c); public Iterator<E> iterator(); public ListIterator<E> listIterator(); public ListIterator<E> listIterator(int index); public List<E> subList(int fromIndex, int toIndex); public boolean equals(Object o); public int hashCode(); protected void removeRange(int fromIndex, int toIndex); protected transient int modCount = 0; } ==================== java/util/AbstractCollection.java ==================== package java.util; public abstract class AbstractCollection<E> implements Collection<E> { protected AbstractCollection(); public abstract Iterator<E> iterator(); public abstract int size(); public boolean isEmpty(); public boolean contains(Object o); public Object[] toArray(); public <T>T[] toArray(T[] a); public boolean add(E o); public boolean remove(Object o); public boolean containsAll(Collection<?> c); public boolean addAll(Collection<? extends E> c); public boolean removeAll(Collection<?> c); public boolean retainAll(Collection<?> c); public void clear(); public String toString(); } ==================== java/util/Collection.java ==================== package java.util; public interface Collection<E> extends Iterable<E> { int size(); boolean isEmpty(); boolean contains(Object o); Iterator<E> iterator(); Object[] toArray(); <T>T[] toArray(T[] a); boolean add(E o); boolean remove(Object o); boolean containsAll(Collection<?> c); boolean addAll(Collection<? extends E> c); boolean removeAll(Collection<?> c); boolean retainAll(Collection<?> c); void clear(); boolean equals(Object o); int hashCode(); } ==================== java/util/List.java ==================== package java.util; public interface List<E> extends Collection<E> { int size(); boolean isEmpty(); boolean contains(Object o); Iterator<E> iterator(); Object[] toArray(); <T>T[] toArray(T[] a); boolean add(E o); boolean remove(Object o); boolean containsAll(Collection<?> c); boolean addAll(Collection<? extends E> c); boolean addAll(int index, Collection<? extends E> c); boolean removeAll(Collection<?> c); boolean retainAll(Collection<?> c); void clear(); boolean equals(Object o); int hashCode(); E get(int index); E set(int index, E element); void add(int index, E element); E remove(int index); int indexOf(Object o); int lastIndexOf(Object o); ListIterator<E> listIterator(); ListIterator<E> listIterator(int index); List<E> subList(int fromIndex, int toIndex); } ==================== java/util/HashSet.java ==================== package java.util; public class HashSet<E> extends AbstractSet<E> implements Set<E>, Cloneable, java.io.Serializable { public HashSet(); public HashSet(Collection<? extends E> c); public HashSet(int initialCapacity, float loadFactor); public HashSet(int initialCapacity); public Iterator<E> iterator(); public int size(); public boolean isEmpty(); public boolean contains(Object o); public boolean add(E o); public boolean remove(Object o); public void clear(); public Object clone(); } ==================== java/util/AbstractSet.java ==================== package java.util; public abstract class AbstractSet<E> extends AbstractCollection<E> implements Set<E> { protected AbstractSet(); public boolean equals(Object o); public int hashCode(); public boolean removeAll(Collection<?> c); } ==================== java/util/Set.java ==================== package java.util; public interface Set<E> extends Collection<E> { int size(); boolean isEmpty(); boolean contains(Object o); Iterator<E> iterator(); Object[] toArray(); <T>T[] toArray(T[] a); boolean add(E o); boolean remove(Object o); boolean containsAll(Collection<?> c); boolean addAll(Collection<? extends E> c); boolean retainAll(Collection<?> c); boolean removeAll(Collection<?> c); void clear(); boolean equals(Object o); int hashCode(); } ==================== java/util/Iterator.java ==================== package java.util; public interface Iterator<E> extends SimpleIterator<E> { boolean hasNext(); E next(); void remove(); } ==================== java/util/LinkedList.java ==================== package java.util; public class LinkedList<E> extends AbstractSequentialList<E> implements List<E>, Cloneable, java.io.Serializable { public LinkedList(); public LinkedList(Collection<? extends E> c); public E getFirst(); public E getLast(); public E removeFirst(); public E removeLast(); public void addFirst(E o); public void addLast(E o); public boolean contains(Object o); public int size(); public boolean add(E o); public boolean remove(Object o); public boolean addAll(Collection<? extends E> c); public boolean addAll(int index, Collection<? extends E> c); public void clear(); public E get(int index); public E set(int index, E element); public void add(int index, E element); public E remove(int index); public int indexOf(Object o); public int lastIndexOf(Object o); public ListIterator<E> listIterator(int index); public Object clone(); public Object[] toArray(); public <T>T[] toArray(T[] a); } ==================== java/util/AbstractSequentialList.java ==================== package java.util; public abstract class AbstractSequentialList<E> extends AbstractList<E> { protected AbstractSequentialList(); public E get(int index); public E set(int index, E element); public void add(int index, E element); public E remove(int index); public boolean addAll(int index, Collection<? extends E> c); public Iterator<E> iterator(); public abstract ListIterator<E> listIterator(int index); } ==================== java/util/LinkedHashSet.java ==================== package java.util; public class LinkedHashSet<E> extends HashSet<E> implements Set<E>, Cloneable, java.io.Serializable { public LinkedHashSet(int initialCapacity, float loadFactor); public LinkedHashSet(int initialCapacity); public LinkedHashSet(); public LinkedHashSet(Collection<? extends E> c); } ==================== java/util/Comparator.java ==================== package java.util; public interface Comparator<T> { int compare(T o1, T o2); boolean equals(Object obj); } ==================== java/util/Enumeration.java ==================== package java.util; public interface Enumeration<E> { boolean hasMoreElements(); E nextElement(); } ==================== java/util/Hashtable.java ==================== package java.util; import java.io.*; public class Hashtable<K, V> extends Dictionary<K, V> implements Map<K, V>, Cloneable, java.io.Serializable { public Hashtable(int initialCapacity, float loadFactor); public Hashtable(int initialCapacity); public Hashtable(); public Hashtable(Map<? extends K, ? extends V> t); public int size(); public boolean isEmpty(); public Enumeration<K> keys(); public Enumeration<V> elements(); public boolean contains(Object value); public boolean containsValue(Object value); public boolean containsKey(Object key); public V get(Object key); protected void rehash(); public V put(K key, V value); public V remove(Object key); public void putAll(Map<? extends K, ? extends V> t); public void clear(); public Object clone(); public String toString(); public Set<K> keySet(); public Set<Map.Entry<K, V>> entrySet(); public Collection<V> values(); public boolean equals(Object o); public int hashCode(); } ==================== java/util/Dictionary.java ==================== package java.util; public abstract class Dictionary<K, V> { public Dictionary(); public abstract int size(); public abstract boolean isEmpty(); public abstract Enumeration<K> keys(); public abstract Enumeration<V> elements(); public abstract V get(Object key); public abstract V put(K key, V value); public abstract V remove(Object key); } ==================== java/util/Map.java ==================== package java.util; public interface Map<K, V> { int size(); boolean isEmpty(); boolean containsKey(Object key); boolean containsValue(Object value); V get(Object key); V put(K key, V value); V remove(Object key); void putAll(Map<? extends K, ? extends V> t); void clear(); Set<K> keySet(); Collection<V> values(); Set<Map.Entry<K, V>> entrySet(); public static interface Entry<K, V> { K getKey(); V getValue(); V setValue(V value); boolean equals(Object o); int hashCode(); } boolean equals(Object o); int hashCode(); } ==================== java/util/HashMap.java ==================== package java.util; import java.io.*; public class HashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>, Cloneable, Serializable { public HashMap(int initialCapacity, float loadFactor); public HashMap(int initialCapacity); public HashMap(); public HashMap(Map<? extends K, ? extends V> m); public int size(); public boolean isEmpty(); public V get(Object key); public boolean containsKey(Object key); public V put(K key, V value); public void putAll(Map<? extends K, ? extends V> m); public V remove(Object key); public void clear(); public boolean containsValue(Object value); public Object clone(); public Set<K> keySet(); public Collection<V> values(); public Set<Map.Entry<K, V>> entrySet(); } ==================== java/util/AbstractMap.java ==================== package java.util; import java.util.Map.Entry; public abstract class AbstractMap<K, V> implements Map<K, V> { protected AbstractMap(); public int size(); public boolean isEmpty(); public boolean containsValue(Object value); public boolean containsKey(Object key); public V get(Object key); public V put(K key, V value); public V remove(Object key); public void putAll(Map<? extends K, ? extends V> t); public void clear(); public Set<K> keySet(); public Collection<V> values(); public abstract Set<Entry<K, V>> entrySet(); public boolean equals(Object o); public int hashCode(); public String toString(); protected Object clone() throws CloneNotSupportedException; } ==================== java/util/Stack.java ==================== package java.util; public class Stack<E> extends Vector<E> { public Stack(); public E push(E item); public E pop(); public E peek(); public boolean empty(); public int search(Object o); } ==================== java/util/Vector.java ==================== package java.util; public class Vector<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable { protected Object[] elementData; protected int elementCount; protected int capacityIncrement; public Vector(int initialCapacity, int capacityIncrement); public Vector(int initialCapacity); public Vector(); public Vector(Collection<? extends E> c); public void copyInto(Object[] anArray); public void trimToSize(); public void ensureCapacity(int minCapacity); public void setSize(int newSize); public int capacity(); public int size(); public boolean isEmpty(); public Enumeration<E> elements(); public boolean contains(Object elem); public int indexOf(Object elem); public int indexOf(Object elem, int index); public int lastIndexOf(Object elem); public int lastIndexOf(Object elem, int index); public E elementAt(int index); public E firstElement(); public E lastElement(); public void setElementAt(E obj, int index); public void removeElementAt(int index); public void insertElementAt(E obj, int index); public void addElement(E obj); public boolean removeElement(Object obj); public void removeAllElements(); public Object clone(); public Object[] toArray(); public <T>T[] toArray(T[] a); public E get(int index); public E set(int index, E element); public boolean add(E o); public boolean remove(Object o); public void add(int index, E element); public E remove(int index); public void clear(); public boolean containsAll(Collection<?> c); public boolean addAll(Collection<? extends E> c); public boolean removeAll(Collection<?> c); public boolean retainAll(Collection<?> c); public boolean addAll(int index, Collection<? extends E> c); public boolean equals(Object o); public int hashCode(); public String toString(); public List<E> subList(int fromIndex, int toIndex); protected void removeRange(int fromIndex, int toIndex); } ==================== java/util/ListIterator.java ==================== package java.util; public interface ListIterator<E> extends Iterator<E> { boolean hasNext(); E next(); boolean hasPrevious(); E previous(); int nextIndex(); int previousIndex(); void remove(); void set(E o); void add(E o); } ==================== java/util/IdentityHashMap.java ==================== package java.util; import java.io.*; public clas
11-06-2004

PUBLIC COMMENTS ...
10-06-2004

EVALUATION See thee suggested fix. These particular signatures have been very carefully selected to maximize compatibility while giving as much typechecking as possible for programs that use generics. ###@###.### 2003-06-20
20-06-2003