classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [generics] Patch: first generics changes


From: Tom Tromey
Subject: [cp-patches] [generics] Patch: first generics changes
Date: 05 Aug 2004 14:51:45 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Here are the first untested changes for the generics branch.  It is
Iterable, an update to Comparable, plus a big part of java.util
collections.  Iterable in particular is needed to test foreach
support.

Tom

2004-08-05  Tom Tromey  <address@hidden>

        * java/lang/Iterable.java: New file.
        * java/lang/Comparable.java, java/util/AbstractCollection.java,
        java/util/AbstractList.java, java/util/AbstractMap.java,
        java/util/AbstractSequentialList.java, java/util/AbstractSet.java,
        java/util/Arrays.java, java/util/Collection.java,
        java/util/Collections.java, java/util/Comparator.java,
        java/util/Dictionary.java, java/util/Enumeration.java,
        java/util/HashMap.java, java/util/HashSet.java,
        java/util/Iterator.java, java/util/LinkedHashSet.java,
        java/util/LinkedList.java, java/util/List.java,
        java/util/ListIterator.java, java/util/Map.java,
        java/util/Set.java, java/util/SortedMap.java,
        java/util/SortedSet.java, java/util/Stack.java,
        java/util/TreeSet.java, java/util/Vector.java: Updated to use
        generics.

Index: java/lang/Comparable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Comparable.java,v
retrieving revision 1.10
diff -u -r1.10 Comparable.java
--- java/lang/Comparable.java 20 Mar 2002 20:04:32 -0000 1.10
+++ java/lang/Comparable.java 5 Aug 2004 20:49:20 -0000
@@ -1,5 +1,5 @@
 /* Comparable.java -- Interface for comparaing objects to obtain an ordering
-   Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2001, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -67,7 +67,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface Comparable
+public interface Comparable<T>
 {
   /**
    * Compares this object with another, and returns a numerical result based
@@ -93,5 +93,5 @@
    * @throws NullPointerException if o is null
    * @throws ClassCastException if o cannot be compared
    */
-  int compareTo(Object o);
+  int compareTo(T o);
 }
Index: java/lang/Iterable.java
===================================================================
RCS file: java/lang/Iterable.java
diff -N java/lang/Iterable.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ java/lang/Iterable.java 5 Aug 2004 20:49:20 -0000
@@ -0,0 +1,46 @@
+/* Iterable.java -- Notes collection over which one may iterate
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package java.lang;
+
+import java.util.Iterator;
+
+public interface Iterable<E>
+{
+  Iterator<E> iterator ();
+}
Index: java/util/AbstractCollection.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractCollection.java,v
retrieving revision 1.14
diff -u -r1.14 AbstractCollection.java
--- java/util/AbstractCollection.java 22 Jan 2002 22:27:01 -0000 1.14
+++ java/util/AbstractCollection.java 5 Aug 2004 20:49:21 -0000
@@ -1,5 +1,5 @@
 /* AbstractCollection.java -- Abstract implementation of most of Collection
-   Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2000, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -68,7 +68,8 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public abstract class AbstractCollection implements Collection
+public abstract class AbstractCollection<E>
+  implements Collection<E>, Iterable<E>
 {
   /**
    * The main constructor, for use by subclasses.
@@ -84,7 +85,7 @@
    *
    * @return an iterator
    */
-  public abstract Iterator iterator();
+  public abstract Iterator<E> iterator();
 
   /**
    * Return the number of elements in this collection. If there are more than
@@ -110,7 +111,7 @@
    * @throws IllegalArgumentException if some aspect of the object prevents
    *         it from being added
    */
-  public boolean add(Object o)
+  public boolean add(E o)
   {
     throw new UnsupportedOperationException();
   }
@@ -136,9 +137,9 @@
    *         it from being added
    * @see #add(Object)
    */
-  public boolean addAll(Collection c)
+  public boolean addAll(Collection<? extends E> c)
   {
-    Iterator itr = c.iterator();
+    Iterator<? extends E> itr = c.iterator();
     boolean modified = false;
     int pos = c.size();
     while (--pos >= 0)
@@ -160,7 +161,7 @@
    */
   public void clear()
   {
-    Iterator itr = iterator();
+    Iterator<E> itr = iterator();
     int pos = size();
     while (--pos >= 0)
       {
@@ -182,7 +183,7 @@
    */
   public boolean contains(Object o)
   {
-    Iterator itr = iterator();
+    Iterator<E> itr = iterator();
     int pos = size();
     while (--pos >= 0)
       if (equals(o, itr.next()))
@@ -202,9 +203,9 @@
    * @throws NullPointerException if the given collection is null
    * @see #contains(Object)
    */
-  public boolean containsAll(Collection c)
+  public boolean containsAll(Collection<?> c)
   {
-    Iterator itr = c.iterator();
+    Iterator<?> itr = c.iterator();
     int pos = c.size();
     while (--pos >= 0)
       if (!contains(itr.next()))
@@ -245,7 +246,7 @@
    */
   public boolean remove(Object o)
   {
-    Iterator itr = iterator();
+    Iterator<E> itr = iterator();
     int pos = size();
     while (--pos >= 0)
       if (equals(o, itr.next()))
@@ -270,7 +271,7 @@
    *         does not support the remove method
    * @see Iterator#remove()
    */
-  public boolean removeAll(Collection c)
+  public boolean removeAll(Collection<?> c)
   {
     return removeAllInternal(c);
   }
@@ -290,9 +291,9 @@
    *         does not support the remove method
    * @see Iterator#remove()
    */
-  boolean removeAllInternal(Collection c)
+  boolean removeAllInternal(Collection<?> c)
   {
-    Iterator itr = iterator();
+    Iterator<E> itr = iterator();
     boolean modified = false;
     int pos = size();
     while (--pos >= 0)
@@ -318,7 +319,7 @@
    *         does not support the remove method
    * @see Iterator#remove()
    */
-  public boolean retainAll(Collection c)
+  public boolean retainAll(Collection<?> c)
   {
     return retainAllInternal(c);
   }
@@ -339,9 +340,9 @@
    *         does not support the remove method
    * @see Iterator#remove()
    */
-  boolean retainAllInternal(Collection c)
+  boolean retainAllInternal(Collection<?> c)
   {
-    Iterator itr = iterator();
+    Iterator<E> itr = iterator();
     boolean modified = false;
     int pos = size();
     while (--pos >= 0)
@@ -364,7 +365,7 @@
    */
   public Object[] toArray()
   {
-    Iterator itr = iterator();
+    Iterator<E> itr = iterator();
     int size = size();
     Object[] a = new Object[size];
     for (int pos = 0; pos < size; pos++)
@@ -394,7 +395,7 @@
    * @throws ArrayStoreException if the type of the array precludes holding
    *         one of the elements of the Collection
    */
-  public Object[] toArray(Object[] a)
+  <T> public T[] toArray(T[] a)
   {
     int size = size();
     if (a.length < size)
@@ -403,7 +404,7 @@
     else if (a.length > size)
       a[size] = null;
 
-    Iterator itr = iterator();
+    Iterator<E> itr = iterator();
     for (int pos = 0; pos < size; pos++)
       a[pos] = itr.next();
 
Index: java/util/AbstractList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractList.java,v
retrieving revision 1.21
diff -u -r1.21 AbstractList.java
--- java/util/AbstractList.java 7 May 2002 05:13:05 -0000 1.21
+++ java/util/AbstractList.java 5 Aug 2004 20:49:21 -0000
@@ -1,5 +1,5 @@
 /* AbstractList.java -- Abstract implementation of most of List
-   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, 
Inc.
 
 This file is part of GNU Classpath.
 
@@ -68,7 +68,9 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public abstract class AbstractList extends AbstractCollection implements List
+public abstract class AbstractList<E>
+  extends AbstractCollection<E>
+  implements List<E>
 {
   /**
    * A count of the number of structural modifications that have been made to
@@ -101,7 +103,7 @@
    * @return the element at that position
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
    */
-  public abstract Object get(int index);
+  public abstract E get(int index);
 
   /**
    * Insert an element into the list at a given position (optional operation).
@@ -123,7 +125,7 @@
    *         some other reason
    * @see #modCount
    */
-  public void add(int index, Object o)
+  public void add(int index, E o)
   {
     throw new UnsupportedOperationException();
   }
@@ -144,7 +146,7 @@
    *         some other reason
    * @see #add(int, Object)
    */
-  public boolean add(Object o)
+  public boolean add(E o)
   {
     add(size(), o);
     return true;
@@ -173,9 +175,9 @@
    * @throws NullPointerException if the specified collection is null
    * @see #add(int, Object)
    */
-  public boolean addAll(int index, Collection c)
+  public boolean addAll(int index, Collection<? extends E> c)
   {
-    Iterator itr = c.iterator();
+    Iterator<? extends E> itr = c.iterator();
     int size = c.size();
     for (int pos = size; pos > 0; pos--)
       add(index++, itr.next());
@@ -227,7 +229,7 @@
     if (size != ((List) o).size())
       return false;
 
-    Iterator itr1 = iterator();
+    Iterator<E> itr1 = iterator();
     Iterator itr2 = ((List) o).iterator();
 
     while (--size >= 0)
@@ -259,7 +261,7 @@
   public int hashCode()
   {
     int hashCode = 1;
-    Iterator itr = iterator();
+    Iterator<E> itr = iterator();
     int pos = size();
     while (--pos >= 0)
       hashCode = 31 * hashCode + hashCode(itr.next());
@@ -277,7 +279,7 @@
    */
   public int indexOf(Object o)
   {
-    ListIterator itr = listIterator();
+    ListIterator<E> itr = listIterator();
     int size = size();
     for (int pos = 0; pos < size; pos++)
       if (equals(o, itr.next()))
@@ -297,10 +299,10 @@
    * @return an Iterator over the elements of this list, in order
    * @see #modCount
    */
-  public Iterator iterator()
+  public Iterator<E> iterator()
   {
     // Bah, Sun's implementation forbids using listIterator(0).
-    return new Iterator()
+    return new Iterator<E>()
     {
       private int pos = 0;
       private int size = size();
@@ -320,7 +322,7 @@
         return pos < size;
       }
 
-      public Object next()
+      public E next()
       {
         checkMod();
         if (pos == size)
@@ -354,7 +356,7 @@
   public int lastIndexOf(Object o)
   {
     int pos = size();
-    ListIterator itr = listIterator(pos);
+    ListIterator<E> itr = listIterator(pos);
     while (--pos >= 0)
       if (equals(o, itr.previous()))
         return pos;
@@ -368,7 +370,7 @@
    * @return a ListIterator over the elements of this list, in order, starting
    *         at the beginning
    */
-  public ListIterator listIterator()
+  public ListIterator<E> listIterator()
   {
     return listIterator(0);
   }
@@ -391,13 +393,13 @@
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
    * @see #modCount
    */
-  public ListIterator listIterator(final int index)
+  public ListIterator<E> listIterator(final int index)
   {
     if (index < 0 || index > size())
       throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
                                           + size());
 
-    return new ListIterator()
+    return new ListIterator<E>()
     {
       private int knownMod = modCount;
       private int position = index;
@@ -423,7 +425,7 @@
         return position > 0;
       }
 
-      public Object next()
+      public E next()
       {
         checkMod();
         if (position == size)
@@ -432,7 +434,7 @@
         return get(position++);
       }
 
-      public Object previous()
+      public E previous()
       {
         checkMod();
         if (position == 0)
@@ -498,7 +500,7 @@
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
    * @see #modCount
    */
-  public Object remove(int index)
+  public E remove(int index)
   {
     throw new UnsupportedOperationException();
   }
@@ -522,7 +524,7 @@
    */
   protected void removeRange(int fromIndex, int toIndex)
   {
-    ListIterator itr = listIterator(fromIndex);
+    ListIterator<E> itr = listIterator(fromIndex);
     for (int index = fromIndex; index < toIndex; index++)
       {
         itr.next();
@@ -545,7 +547,7 @@
    * @throws IllegalArgumentException if o cannot be added to this list for
    *         some other reason
    */
-  public Object set(int index, Object o)
+  public E set(int index, E o)
   {
     throw new UnsupportedOperationException();
   }
@@ -594,7 +596,7 @@
    * @see ConcurrentModificationException
    * @see RandomAccess
    */
-  public List subList(int fromIndex, int toIndex)
+  public List<E> subList(int fromIndex, int toIndex)
   {
     // This follows the specification of AbstractList, but is inconsistent
     // with the one in List. Don't you love Sun's inconsistencies?
@@ -604,8 +606,8 @@
       throw new IndexOutOfBoundsException();
 
     if (this instanceof RandomAccess)
-      return new RandomAccessSubList(this, fromIndex, toIndex);
-    return new SubList(this, fromIndex, toIndex);
+      return new RandomAccessSubList<E>(this, fromIndex, toIndex);
+    return new SubList<E>(this, fromIndex, toIndex);
   }
 
 } // class AbstractList
@@ -619,11 +621,11 @@
  * @author Original author unknown
  * @author Eric Blake <address@hidden>
  */
-class SubList extends AbstractList
+class SubList<E> extends AbstractList<E>
 {
   // Package visible, for use by iterator.
   /** The original list. */
-  final AbstractList backingList;
+  final AbstractList<E> backingList;
   /** The index of the first element of the sublist. */
   final int offset;
   /** The size of the sublist. */
@@ -636,7 +638,7 @@
    * @param fromIndex the lower bound, inclusive
    * @param toIndex the upper bound, exclusive
    */
-  SubList(AbstractList backing, int fromIndex, int toIndex)
+  SubList(AbstractList<E> backing, int fromIndex, int toIndex)
   {
     backingList = backing;
     modCount = backing.modCount;
@@ -706,7 +708,7 @@
    * @param o the new value
    * @return the old value
    */
-  public Object set(int index, Object o)
+  public E set(int index, E o)
   {
     checkMod();
     checkBoundsExclusive(index);
@@ -719,7 +721,7 @@
    * @param index the location to get from
    * @return the object at that location
    */
-  public Object get(int index)
+  public E get(int index)
   {
     checkMod();
     checkBoundsExclusive(index);
@@ -732,7 +734,7 @@
    * @param index the index to insert at
    * @param o the object to add
    */
-  public void add(int index, Object o)
+  public void add(int index, E o)
   {
     checkMod();
     checkBoundsInclusive(index);
@@ -747,11 +749,11 @@
    * @param index the index to remove
    * @return the removed object
    */
-  public Object remove(int index)
+  public E remove(int index)
   {
     checkMod();
     checkBoundsExclusive(index);
-    Object o = backingList.remove(index + offset);
+    E o = backingList.remove(index + offset);
     size--;
     modCount = backingList.modCount;
     return o;
@@ -781,7 +783,7 @@
    * @param c the collection to insert
    * @return true if this list was modified, in other words, c is non-empty
    */
-  public boolean addAll(int index, Collection c)
+  public boolean addAll(int index, Collection<? extends E> c)
   {
     checkMod();
     checkBoundsInclusive(index);
@@ -798,7 +800,7 @@
    * @param c the collection to insert
    * @return true if this list was modified, in other words, c is non-empty
    */
-  public boolean addAll(Collection c)
+  public boolean addAll(Collection<? extends E> c)
   {
     return addAll(size, c);
   }
@@ -808,7 +810,7 @@
    *
    * @return an iterator over the sublist
    */
-  public Iterator iterator()
+  public Iterator<E> iterator()
   {
     return listIterator();
   }
@@ -820,14 +822,15 @@
    * @param index the start location of the iterator
    * @return a list iterator over the sublist
    */
-  public ListIterator listIterator(final int index)
+  public ListIterator<E> listIterator(final int index)
   {
     checkMod();
     checkBoundsInclusive(index);
 
-    return new ListIterator()
+    return new ListIterator<E>()
     {
-      private final ListIterator i = backingList.listIterator(index + offset);
+      private final ListIterator<E> i
+       = backingList.listIterator(index + offset);
       private int position = index;
 
       public boolean hasNext()
@@ -842,7 +845,7 @@
         return position > 0;
       }
 
-      public Object next()
+      public E next()
       {
         if (position == size)
           throw new NoSuchElementException();
@@ -850,7 +853,7 @@
         return i.next();
       }
 
-      public Object previous()
+      public E previous()
       {
         if (position == 0)
           throw new NoSuchElementException();
@@ -876,12 +879,12 @@
         modCount = backingList.modCount;
       }
 
-      public void set(Object o)
+      public void set(E o)
       {
         i.set(o);
       }
 
-      public void add(Object o)
+      public void add(E o)
       {
         i.add(o);
         size++;
@@ -917,8 +920,8 @@
  *
  * @author Eric Blake <address@hidden>
  */
-final class RandomAccessSubList extends SubList
-  implements RandomAccess
+final class RandomAccessSubList<E> extends SubList<E>
+  implements RandomAccess<E>
 {
   /**
    * Construct the sublist.
@@ -927,7 +930,7 @@
    * @param fromIndex the lower bound, inclusive
    * @param toIndex the upper bound, exclusive
    */
-  RandomAccessSubList(AbstractList backing, int fromIndex, int toIndex)
+  RandomAccessSubList(AbstractList<E> backing, int fromIndex, int toIndex)
   {
     super(backing, fromIndex, toIndex);
   }
Index: java/util/AbstractMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractMap.java,v
retrieving revision 1.26
diff -u -r1.26 AbstractMap.java
--- java/util/AbstractMap.java 6 Nov 2002 14:03:43 -0000 1.26
+++ java/util/AbstractMap.java 5 Aug 2004 20:49:21 -0000
@@ -1,5 +1,5 @@
 /* AbstractMap.java -- Abstract implementation of most of Map
-   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, 
Inc.
 
 This file is part of GNU Classpath.
 
@@ -64,7 +64,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public abstract class AbstractMap implements Map
+public abstract class AbstractMap<K, V> implements Map<K, V>
 {
   /** An "enum" of iterator types. */
   // Package visible for use by subclasses.
@@ -76,13 +76,13 @@
    * The cache for address@hidden #keySet()}.
    */
   // Package visible for use by subclasses.
-  Set keys;
+  Set<K> keys;
 
   /**
    * The cache for address@hidden #values()}.
    */
   // Package visible for use by subclasses.
-  Collection values;
+  Collection<V> values;
 
   /**
    * The main constructor, for use by subclasses.
@@ -140,10 +140,10 @@
    */
   public boolean containsKey(Object key)
   {
-    Iterator entries = entrySet().iterator();
+    Iterator<Map.Entry<K, V>> entries = entrySet().iterator();
     int pos = size();
     while (--pos >= 0)
-      if (equals(key, ((Map.Entry) entries.next()).getKey()))
+      if (equals(key, entries.next().getKey()))
         return true;
     return false;
   }
@@ -162,10 +162,10 @@
    */
   public boolean containsValue(Object value)
   {
-    Iterator entries = entrySet().iterator();
+    Iterator<Map.Entry<K, V>> entries = entrySet().iterator();
     int pos = size();
     while (--pos >= 0)
-      if (equals(value, ((Map.Entry) entries.next()).getValue()))
+      if (equals(value, entries.next().getValue()))
         return true;
     return false;
   }
@@ -183,7 +183,7 @@
    * @return the entry set
    * @see Map.Entry
    */
-  public abstract Set entrySet();
+  public abstract Set<Map.Entry<K, V>> entrySet();
 
   /**
    * Compares the specified object with this map for equality. Returns
@@ -197,9 +197,9 @@
    */
   public boolean equals(Object o)
   {
-    return (o == this ||
-            (o instanceof Map &&
-             entrySet().equals(((Map) o).entrySet())));
+    return (o == this
+           || (o instanceof Map
+               && entrySet().equals(((Map) o).entrySet())));
   }
 
   /**
@@ -214,13 +214,13 @@
    * @throws NullPointerException if this map does not accept null keys
    * @see #containsKey(Object)
    */
-  public Object get(Object key)
+  public V get(Object key)
   {
-    Iterator entries = entrySet().iterator();
+    Iterator<Map.Entry<K, V>> entries = entrySet().iterator();
     int pos = size();
     while (--pos >= 0)
       {
-        Map.Entry entry = (Map.Entry) entries.next();
+        Map.Entry<K, V> entry = entries.next();
         if (equals(key, entry.getKey()))
           return entry.getValue();
       }
@@ -272,10 +272,10 @@
    * @see #containsKey(Object)
    * @see #values()
    */
-  public Set keySet()
+  public Set<K> keySet()
   {
     if (keys == null)
-      keys = new AbstractSet()
+      keys = new AbstractSet<K>()
       {
         public int size()
         {
@@ -287,20 +287,21 @@
           return containsKey(key);
         }
 
-        public Iterator iterator()
+        public Iterator<K> iterator()
         {
           return new Iterator()
           {
-            private final Iterator map_iterator = entrySet().iterator();
+            private final Iterator<Map.Entry<K, V>> map_iterator
+             = entrySet().iterator();
 
             public boolean hasNext()
             {
               return map_iterator.hasNext();
             }
 
-            public Object next()
+            public K next()
             {
-              return ((Map.Entry) map_iterator.next()).getKey();
+              return map_iterator.next().getKey();
             }
 
             public void remove()
@@ -330,7 +331,7 @@
    * @throws NullPointerException if the map forbids null keys or values
    * @see #containsKey(Object)
    */
-  public Object put(Object key, Object value)
+  public V put(K key, V value)
   {
     throw new UnsupportedOperationException();
   }
@@ -350,13 +351,13 @@
    *         if <code>m</code> is null.
    * @see #put(Object, Object)
    */
-  public void putAll(Map m)
+  public void putAll(Map<? extends K, ? extends V> m)
   {
-    Iterator entries = m.entrySet().iterator();
+    Iterator<Map.Entry<K, V>> entries = m.entrySet().iterator();
     int pos = m.size();
     while (--pos >= 0)
       {
-        Map.Entry entry = (Map.Entry) entries.next();
+        Map.Entry<K, V> entry = entries.next();
         put(entry.getKey(), entry.getValue());
       }
   }
@@ -376,17 +377,17 @@
    * @throws UnsupportedOperationException if deletion is unsupported
    * @see Iterator#remove()
    */
-  public Object remove(Object key)
+  public V remove(Object key)
   {
-    Iterator entries = entrySet().iterator();
+    Iterator<Map.Entry<K, V>> entries = entrySet().iterator();
     int pos = size();
     while (--pos >= 0)
       {
-        Map.Entry entry = (Map.Entry) entries.next();
+        Map.Entry<K, V> entry = entries.next();
         if (equals(key, entry.getKey()))
           {
             // Must get the value before we remove it from iterator.
-            Object r = entry.getValue();
+            V r = entry.getValue();
             entries.remove();
             return r;
           }
@@ -421,11 +422,11 @@
    */
   public String toString()
   {
-    Iterator entries = entrySet().iterator();
+    Iterator<Map.Entry<K, V>> entries = entrySet().iterator();
     StringBuffer r = new StringBuffer("{");
     for (int pos = size(); pos > 0; pos--)
       {
-        Map.Entry entry = (Map.Entry) entries.next();
+        Map.Entry<K, V> entry = entries.next();
         r.append(entry.getKey());
         r.append('=');
         r.append(entry.getValue());
@@ -456,10 +457,10 @@
    * @see #containsValue(Object)
    * @see #keySet()
    */
-  public Collection values()
+  public Collection<V> values()
   {
     if (values == null)
-      values = new AbstractCollection()
+      values = new AbstractCollection<V>()
       {
         public int size()
         {
@@ -471,20 +472,21 @@
           return containsValue(value);
         }
 
-        public Iterator iterator()
+        public Iterator<V> iterator()
         {
           return new Iterator()
           {
-            private final Iterator map_iterator = entrySet().iterator();
+            private final Iterator<Map.Entry<K, V>> map_iterator
+             = entrySet().iterator();
 
             public boolean hasNext()
             {
               return map_iterator.hasNext();
             }
 
-            public Object next()
+            public V next()
             {
-              return ((Map.Entry) map_iterator.next()).getValue();
+              return map_iterator.next().getValue();
             }
 
             public void remove()
@@ -533,24 +535,24 @@
    * @author Eric Blake <address@hidden>
    */
   // XXX - FIXME Use fully qualified implements as gcj 3.1 workaround.
-  static class BasicMapEntry implements Map.Entry
+  static class BasicMapEntry<K, V> implements Map.Entry<K, V>
   {
     /**
      * The key. Package visible for direct manipulation.
      */
-    Object key;
+    K key;
 
     /**
      * The value. Package visible for direct manipulation.
      */
-    Object value;
+    V value;
 
     /**
      * Basic constructor initializes the fields.
      * @param newKey the key
      * @param newValue the value
      */
-    BasicMapEntry(Object newKey, Object newValue)
+    BasicMapEntry(K newKey, V newValue)
     {
       key = newKey;
       value = newValue;
@@ -590,7 +592,7 @@
      *
      * @return the key
      */
-    public final Object getKey()
+    public final K getKey()
     {
       return key;
     }
@@ -601,7 +603,7 @@
      *
      * @return the value
      */
-    public final Object getValue()
+    public final V getValue()
     {
       return value;
     }
@@ -629,9 +631,9 @@
      * @return the old value
      * @throws NullPointerException if the map forbids null values
      */
-    public Object setValue(Object newVal)
+    public V setValue(V newVal)
     {
-      Object r = value;
+      V r = value;
       value = newVal;
       return r;
     }
Index: java/util/AbstractSequentialList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractSequentialList.java,v
retrieving revision 1.15
diff -u -r1.15 AbstractSequentialList.java
--- java/util/AbstractSequentialList.java 23 Jan 2002 00:06:10 -0000 1.15
+++ java/util/AbstractSequentialList.java 5 Aug 2004 20:49:21 -0000
@@ -1,5 +1,5 @@
 /* AbstractSequentialList.java -- List implementation for sequential access
-   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -71,7 +71,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public abstract class AbstractSequentialList extends AbstractList
+public abstract class AbstractSequentialList<E> extends AbstractList<E>
 {
   /**
    * The main constructor, for use by subclasses.
@@ -88,7 +88,7 @@
    * @return the list iterator
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
    */
-  public abstract ListIterator listIterator(int index);
+  public abstract ListIterator<E> listIterator(int index);
 
   /**
    * Insert an element into the list at a given position (optional operation).
@@ -107,7 +107,7 @@
    * @throws IllegalArgumentException if o cannot be added to this list for
    *         some other reason
    */
-  public void add(int index, Object o)
+  public void add(int index, E o)
   {
     listIterator(index).add(o);
   }
@@ -139,9 +139,9 @@
    * @throws NullPointerException if the specified collection is null
    * @see #add(int, Object)
    */
-  public boolean addAll(int index, Collection c)
+  public boolean addAll(int index, Collection<? extends E> c)
   {
-    Iterator ci = c.iterator();
+    Iterator<? extends E> ci = c.iterator();
     int size = c.size();
     ListIterator i = listIterator(index);
     for (int pos = size; pos > 0; pos--)
@@ -157,7 +157,7 @@
    * @return the element at index index in this list
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
    */
-  public Object get(int index)
+  public E get(int index)
   {
     // This is a legal listIterator position, but an illegal get.
     if (index == size())
@@ -172,7 +172,7 @@
    *
    * @return an Iterator over the elements of this list, in order
    */
-  public Iterator iterator()
+  public Iterator<E> iterator()
   {
     return listIterator();
   }
@@ -188,14 +188,14 @@
    *         remove operation
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
    */
-  public Object remove(int index)
+  public E remove(int index)
   {
     // This is a legal listIterator position, but an illegal remove.
     if (index == size())
       throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
                                           + size());
-    ListIterator i = listIterator(index);
-    Object removed = i.next();
+    ListIterator<E> i = listIterator(index);
+    E removed = i.next();
     i.remove();
     return removed;
   }
@@ -215,14 +215,14 @@
    * @throws IllegalArgumentException if o cannot be added to this list for
    *         some other reason
    */
-  public Object set(int index, Object o)
+  public E set(int index, E o)
   {
     // This is a legal listIterator position, but an illegal set.
     if (index == size())
       throw new IndexOutOfBoundsException("Index: " + index + ", Size:"
                                           + size());
-    ListIterator i = listIterator(index);
-    Object old = i.next();
+    ListIterator<E> i = listIterator(index);
+    E old = i.next();
     i.set(o);
     return old;
   }
Index: java/util/AbstractSet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/AbstractSet.java,v
retrieving revision 1.14
diff -u -r1.14 AbstractSet.java
--- java/util/AbstractSet.java 23 Jan 2002 00:06:10 -0000 1.14
+++ java/util/AbstractSet.java 5 Aug 2004 20:49:21 -0000
@@ -1,5 +1,5 @@
 /* AbstractSet.java -- Abstract implementation of most of Set
-   Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2000, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -58,7 +58,9 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public abstract class AbstractSet extends AbstractCollection implements Set
+public abstract class AbstractSet<E>
+  extends AbstractCollection<E>
+  implements Set<E>
 {
   /**
    * The main constructor, for use by subclasses.
@@ -79,9 +81,9 @@
    */
   public boolean equals(Object o)
   {
-    return (o == this ||
-            (o instanceof Set && ((Set) o).size() == size()
-             && containsAll((Collection) o)));
+    return (o == this
+           || (o instanceof Set && ((Set) o).size() == size()
+               && containsAll((Collection) o)));
   }
 
   /**
@@ -94,7 +96,7 @@
    */
   public int hashCode()
   {
-    Iterator itr = iterator();
+    Iterator<E> itr = iterator();
     int hash = 0;
     int pos = size();
     while (--pos >= 0)
@@ -119,11 +121,11 @@
    * @see Collection#contains(Object)
    * @see Iterator#remove()
    */
-  public boolean removeAll(Collection c)
+  public boolean removeAll(Collection<?> c)
   {
     int oldsize = size();
     int count = c.size();
-    Iterator i;
+    Iterator<E> i;
     if (oldsize < count)
       {
        for (i = iterator(), count = oldsize; count > 0; count--)
Index: java/util/Arrays.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Arrays.java,v
retrieving revision 1.20
diff -u -r1.20 Arrays.java
--- java/util/Arrays.java 23 Apr 2004 17:37:47 -0000 1.20
+++ java/util/Arrays.java 5 Aug 2004 20:49:22 -0000
@@ -1,5 +1,5 @@
 /* Arrays.java -- Utility class with methods to operate on arrays
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, 
Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software 
Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -361,7 +361,8 @@
    * @throws NullPointerException if a null element is compared with natural
    *         ordering (only possible when c is null)
    */
-  public static int binarySearch(Object[] a, Object key, Comparator c)
+  // FIXME why "super"?
+  <T> public static int binarySearch(T[] a, T key, Comparator<? super T> c)
   {
     int low = 0;
     int hi = a.length - 1;
@@ -2148,7 +2149,7 @@
    * @throws NullPointerException if a null element is compared with natural
    *         ordering (only possible when c is null)
    */
-  public static void sort(Object[] a, Comparator c)
+  public static void sort(T[] a, Comparator<? super T> c)
   {
     sort(a, 0, a.length, c);
   }
@@ -2198,7 +2199,8 @@
    * @throws NullPointerException if a null element is compared with natural
    *         ordering (only possible when c is null)
    */
-  public static void sort(Object[] a, int fromIndex, int toIndex, Comparator c)
+  public static void sort(T[] a, int fromIndex, int toIndex,
+                         Comparator<? super T> c)
   {
     if (fromIndex > toIndex)
       throw new IllegalArgumentException("fromIndex " + fromIndex
@@ -2330,7 +2332,7 @@
    * @see RandomAccess
    * @see Arrays.ArrayList
    */
-  public static List asList(final Object[] a)
+  <T> public static List<T> asList(final Object[] a) // fixme `T...'
   {
     return new Arrays.ArrayList(a);
   }
Index: java/util/Collection.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Collection.java,v
retrieving revision 1.9
diff -u -r1.9 Collection.java
--- java/util/Collection.java 29 Jul 2004 20:23:18 -0000 1.9
+++ java/util/Collection.java 5 Aug 2004 20:49:22 -0000
@@ -1,5 +1,5 @@
 /* Collection.java -- Interface that represents a collection of objects
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -83,7 +83,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface Collection
+public interface Collection<E> extends Iterable<E>
 {
   /**
    * Add an element to this collection.
@@ -99,7 +99,7 @@
    * @throws IllegalArgumentException if o cannot be added to this
    *   collection for some other reason.
    */
-  boolean add(Object o);
+  boolean add(E o);
 
   /**
    * Add the contents of a given collection to this collection.
@@ -116,7 +116,7 @@
    * @throws IllegalArgumentException if some element of c cannot be added
    *   to this collection for some other reason.
    */
-  boolean addAll(Collection c);
+  boolean addAll(Collection<? extends E> c);
 
   /**
    * Clear the collection, such that a subsequent call to isEmpty() would
@@ -232,7 +232,7 @@
    *   collection does not support removing null values.
    * @throws NullPointerException if c itself is null.
    */
-  boolean removeAll(Collection c);
+  boolean removeAll(Collection<?> c);
 
   /**
    * Remove all elements of this collection that are not contained in a given
@@ -247,7 +247,7 @@
    *   collection does not support retaining null values.
    * @throws NullPointerException if c itself is null.
    */
-  boolean retainAll(Collection c);
+  boolean retainAll(Collection<?> c);
 
   /**
    * Get the number of elements in this collection.
@@ -282,5 +282,5 @@
    * @throws ArrayStoreException if the type of any element of the
    *   collection is not a subtype of the element type of a.
    */
-  Object[] toArray(Object[] a);
+  <T> T[] toArray(T[] a);
 }
Index: java/util/Collections.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Collections.java,v
retrieving revision 1.28
diff -u -r1.28 Collections.java
--- java/util/Collections.java 17 Apr 2004 19:23:19 -0000 1.28
+++ java/util/Collections.java 5 Aug 2004 20:49:22 -0000
@@ -1,5 +1,5 @@
 /* Collections.java -- Utility class with methods to operate on collections
-   Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, 
Inc.
 
 This file is part of GNU Classpath.
 
@@ -530,7 +530,8 @@
    * @throws NullPointerException if a null element has compareTo called
    * @see #sort(List)
    */
-  public static int binarySearch(List l, Object key)
+  <T extends Object & Comparable<? super T>>
+  public static int binarySearch(List<? extends T> l, T key)
   {
     return binarySearch(l, key, null);
   }
@@ -562,7 +563,7 @@
    *         ordering (only possible when c is null)
    * @see #sort(List, Comparator)
    */
-  public static int binarySearch(List l, Object key, Comparator c)
+  <T> public static int binarySearch(List<T> l, T key, Comparator<? super T> c)
   {
     int pos = 0;
     int low = 0;
@@ -572,7 +573,7 @@
     // if the list is sequential-access.
     if (isSequential(l))
       {
-       ListIterator itr = l.listIterator();
+       ListIterator<T> itr = l.listIterator();
         int i = 0;
         while (low <= hi)
           {
@@ -623,14 +624,14 @@
    * @throws UnsupportedOperationException if dest.listIterator() does not
    *         support the set operation
    */
-  public static void copy(List dest, List source)
+  <T> public static void copy(List<T> dest, List<T> source)
   {
     int pos = source.size();
     if (dest.size() < pos)
       throw new IndexOutOfBoundsException("Source does not fit in dest");
 
-    Iterator i1 = source.iterator();
-    ListIterator i2 = dest.listIterator();
+    Iterator<T> i1 = source.iterator();
+    ListIterator<T> i2 = dest.listIterator();
 
     while (--pos >= 0)
       {
@@ -646,16 +647,16 @@
    * @param c the Collection to iterate over
    * @return an Enumeration backed by an Iterator over c
    */
-  public static Enumeration enumeration(Collection c)
+  <T> public static Enumeration<T> enumeration(Collection<T> c)
   {
-    final Iterator i = c.iterator();
-    return new Enumeration()
+    final Iterator<T> i = c.iterator();
+    return new Enumeration<T>()
     {
       public final boolean hasMoreElements()
       {
        return i.hasNext();
       }
-      public final Object nextElement()
+      public final T nextElement()
       {
        return i.next();
       }
@@ -671,9 +672,9 @@
    * @throws UnsupportedOperationException if l.listIterator() does not
    *         support the set operation.
    */
-  public static void fill(List l, Object val)
+  <T> public static void fill(List<T> l, T val)
   {
-    ListIterator itr = l.listIterator();
+    ListIterator<T> itr = l.listIterator();
     for (int i = l.size() - 1; i >= 0; --i)
       {
        itr.next();
@@ -694,7 +695,7 @@
    * @return the index where found, or -1
    * @since 1.4
    */
-  public static int indexOfSubList(List source, List target)
+  public static int indexOfSubList(List<?> source, List<?> target)
   {
     int ssize = source.size();
     for (int i = 0, j = target.size(); j <= ssize; i++, j++)
@@ -716,7 +717,7 @@
    * @return the index where found, or -1
    * @since 1.4
    */
-  public static int lastIndexOfSubList(List source, List target)
+  public static int lastIndexOfSubList(List<?> source, List<?> target)
   {
     int ssize = source.size();
     for (int i = ssize - target.size(), j = ssize; i >= 0; i--, j--)
@@ -735,9 +736,9 @@
    * @see ArrayList
    * @since 1.4
    */
-  public static ArrayList list(Enumeration e)
+  <T> public static ArrayList<T> list(Enumeration<T> e)
   {
-    ArrayList l = new ArrayList();
+    ArrayList<T> l = new ArrayList<T>();
     while (e.hasMoreElements())
       l.add(e.nextElement());
     return l;
@@ -754,7 +755,8 @@
    * @exception ClassCastException if elements in c are not mutually comparable
    * @exception NullPointerException if null.compareTo is called
    */
-  public static Object max(Collection c)
+  <T extends Object & Comparable<? super T>>
+  public static T max(Collection<? extends T> c)
   {
     return max(c, null);
   }
@@ -773,14 +775,15 @@
    * @throws NullPointerException if null is compared by natural ordering
    *        (only possible when order is null)
    */
-  public static Object max(Collection c, Comparator order)
+  <T> public static T max(Collection<? extends T> c,
+                         Comparator<? super T> order)
   {
-    Iterator itr = c.iterator();
-    Object max = itr.next(); // throws NoSuchElementException
+    Iterator<? extends T> itr = c.iterator();
+    T max = itr.next(); // throws NoSuchElementException
     int csize = c.size();
     for (int i = 1; i < csize; i++)
       {
-       Object o = itr.next();
+       T o = itr.next();
        if (compare(max, o, order) < 0)
          max = o;
       }
@@ -798,7 +801,8 @@
    * @throws ClassCastException if elements in c are not mutually comparable
    * @throws NullPointerException if null.compareTo is called
    */
-  public static Object min(Collection c)
+  <T extends Object & Comparable<? super T>>
+  public static T min(Collection<? extends T> c)
   {
     return min(c, null);
   }
@@ -817,14 +821,15 @@
    * @throws NullPointerException if null is compared by natural ordering
    *        (only possible when order is null)
    */
-  public static Object min(Collection c, Comparator order)
+  <T> public static T min(Collection<? extends T> c,
+                         Comparator<? super T> order)
   {
-    Iterator itr = c.iterator();
-    Object min = itr.next();   // throws NoSuchElementExcception
+    Iterator<T> itr = c.iterator();
+    T min = itr.next();        // throws NoSuchElementExcception
     int csize = c.size();
     for (int i = 1; i < csize; i++)
       {
-       Object o = itr.next();
+       T o = itr.next();
        if (compare(min, o, order) > 0)
          min = o;
       }
@@ -846,9 +851,9 @@
    * @see Serializable
    * @see RandomAccess
    */
-  public static List nCopies(final int n, final Object o)
+  <T> public static List<T> nCopies(final int n, final T o)
   {
-    return new CopiesList(n, o);
+    return new CopiesList<T>(n, o);
   }
 
   /**
@@ -857,7 +862,7 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class CopiesList extends AbstractList
+  private static final class CopiesList<T> extends AbstractList<T>
     implements Serializable, RandomAccess
   {
     /**
@@ -875,7 +880,7 @@
      * The repeated list element.
      * @serial the list contents
      */
-    private final Object element;
+    private final T element;
 
     /**
      * Constructs the list.
@@ -884,7 +889,7 @@
      * @param o the object
      * @throws IllegalArgumentException if n &lt; 0
      */
-    CopiesList(int n, Object o)
+    CopiesList(int n, T o)
     {
       if (n < 0)
        throw new IllegalArgumentException();
@@ -903,7 +908,7 @@
     /**
      * The same element is returned.
      */
-    public Object get(int index)
+    public T get(int index)
     {
       if (index < 0 || index >= n)
         throw new IndexOutOfBoundsException();
@@ -939,11 +944,11 @@
     /**
      * A subList is just another CopiesList.
      */
-    public List subList(int from, int to)
+    public List<T> subList(int from, int to)
     {
       if (from < 0 || to > n)
         throw new IndexOutOfBoundsException();
-      return new CopiesList(to - from, element);
+      return new CopiesList<T>(to - from, element);
     }
 
     /**
@@ -986,9 +991,9 @@
    *         it being added to the list
    * @since 1.4
    */
-  public static boolean replaceAll(List list, Object oldval, Object newval)
+  <T> public static boolean replaceAll(List<T> list, T oldval, T newval)
   {
-    ListIterator itr = list.listIterator();
+    ListIterator<T> itr = list.listIterator();
     boolean replace_occured = false;
     for (int i = list.size(); --i >= 0; )
       if (AbstractCollection.equals(oldval, itr.next()))
@@ -1006,12 +1011,12 @@
    * @throws UnsupportedOperationException if l.listIterator() does not
    *         support the set operation
    */
-  public static void reverse(List l)
+  <T> public static void reverse(List<T> l)
   {
-    ListIterator i1 = l.listIterator();
+    ListIterator<T> i1 = l.listIterator();
     int pos1 = 1;
     int pos2 = l.size();
-    ListIterator i2 = l.listIterator(pos2);
+    ListIterator<T> i2 = l.listIterator(pos2);
     while (pos1 < pos2)
       {
        Object o = i1.next();
@@ -1033,9 +1038,9 @@
    * @see Comparable
    * @see Serializable
    */
-  public static Comparator reverseOrder()
+  <T>public static Comparator<T> reverseOrder<T>()
   {
-    return rcInstance;
+    return (Comparator<T>) rcInstance; // fixme?
   }
 
   /**
@@ -1049,8 +1054,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class ReverseComparator
-    implements Comparator, Serializable
+  private static final class ReverseComparator<T>
+    implements Comparator<T>, Serializable
   {
     /**
      * Compatible with JDK 1.4.
@@ -1107,7 +1112,7 @@
    * @throws UnsupportedOperationException if the list does not support set
    * @since 1.4
    */
-  public static void rotate(List list, int distance)
+  public static void rotate(List<?> list, int distance)
   {
     int size = list.size();
     distance %= size;
@@ -1169,7 +1174,7 @@
    * @throws UnsupportedOperationException if l.listIterator() does not
    *         support the set operation
    */
-  public static void shuffle(List l)
+  public static void shuffle(List<?> l)
   {
     if (defaultRandom == null)
       {
@@ -1212,7 +1217,7 @@
    * @throws UnsupportedOperationException if l.listIterator() does not
    *         support the set operation
    */
-  public static void shuffle(List l, Random r)
+  public static void shuffle(List<?> l, Random r)
   {
     int lsize = l.size();
     ListIterator i = l.listIterator(lsize);
@@ -1251,9 +1256,9 @@
    * @return an immutable Set containing only o
    * @see Serializable
    */
-  public static Set singleton(Object o)
+  <T> public static Set<T> singleton(T o)
   {
-    return new SingletonSet(o);
+    return new SingletonSet<T>(o);
   }
 
   /**
@@ -1262,7 +1267,7 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class SingletonSet extends AbstractSet
+  private static final class SingletonSet<T> extends AbstractSet<T>
     implements Serializable
   {
     /**
@@ -1275,13 +1280,13 @@
      * The single element; package visible for use in nested class.
      * @serial the singleton
      */
-    final Object element;
+    final T element;
 
     /**
      * Construct a singleton.
      * @param o the element
      */
-    SingletonSet(Object o)
+    SingletonSet(T o)
     {
       element = o;
     }
@@ -1297,9 +1302,9 @@
     /**
      * Returns an iterator over the lone element.
      */
-    public Iterator iterator()
+    public Iterator<T> iterator()
     {
-      return new Iterator()
+      return new Iterator<T>()
       {
         private boolean hasNext = true;
 
@@ -1308,7 +1313,7 @@
           return hasNext;
         }
 
-        public Object next()
+        public T next()
         {
           if (hasNext)
           {
@@ -1384,9 +1389,9 @@
    * @see RandomAccess
    * @since 1.3
    */
-  public static List singletonList(Object o)
+  <T> public static List<T> singletonList(T o)
   {
-    return new SingletonList(o);
+    return new SingletonList<T>(o);
   }
 
   /**
@@ -1395,7 +1400,7 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class SingletonList extends AbstractList
+  private static final class SingletonList<T> extends AbstractList<T>
     implements Serializable, RandomAccess
   {
     /**
@@ -1407,13 +1412,13 @@
      * The single element.
      * @serial the singleton
      */
-    private final Object element;
+    private final T element;
 
     /**
      * Construct a singleton.
      * @param o the element
      */
-    SingletonList(Object o)
+    SingletonList(T o)
     {
       element = o;
     }
@@ -1429,7 +1434,7 @@
     /**
      * Only index 0 is valid.
      */
-    public Object get(int index)
+    public T get(int index)
     {
       if (index == 0)
         return element;
@@ -1486,7 +1491,7 @@
     /**
      * Sublists are limited in scope.
      */
-    public List subList(int from, int to)
+    public List<T> subList(int from, int to)
     {
       if (from == to && (to == 0 || to == 1))
         return EMPTY_LIST;
@@ -1524,9 +1529,9 @@
    * @see Serializable
    * @since 1.3
    */
-  public static Map singletonMap(Object key, Object value)
+  <K, V> public static Map<K, V> singletonMap(K key, V value)
   {
-    return new SingletonMap(key, value);
+    return new SingletonMap<K, V>(key, value);
   }
 
   /**
@@ -1535,7 +1540,7 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class SingletonMap extends AbstractMap
+  private static final class SingletonMap<K, V> extends AbstractMap<K, V>
     implements Serializable
   {
     /**
@@ -1547,25 +1552,25 @@
      * The single key.
      * @serial the singleton key
      */
-    private final Object k;
+    private final K k;
 
     /**
      * The corresponding value.
      * @serial the singleton value
      */
-    private final Object v;
+    private final V v;
 
     /**
      * Cache the entry set.
      */
-    private transient Set entries;
+    private transient Set<BasicMapEntry<K, V>> entries;
 
     /**
      * Construct a singleton.
      * @param key the key
      * @param value the value
      */
-    SingletonMap(Object key, Object value)
+    SingletonMap(K key, V value)
     {
       k = key;
       v = value;
@@ -1574,12 +1579,12 @@
     /**
      * There is a single immutable entry.
      */
-    public Set entrySet()
+    public Set<BasicMapEntry<K, V>> entrySet()
     {
       if (entries == null)
-        entries = singleton(new AbstractMap.BasicMapEntry(k, v)
+        entries = singleton(new AbstractMap.BasicMapEntry<K, V>(k, v)
         {
-          public Object setValue(Object o)
+          public V setValue(V o)
           {
             throw new UnsupportedOperationException();
           }
@@ -1608,7 +1613,7 @@
     /**
      * Single entry.
      */
-    public Object get(Object key)
+    public V get(K key)
     {
       return equals(key, k) ? v : null;
     }
@@ -1624,7 +1629,7 @@
     /**
      * Return the keyset.
      */
-    public Set keySet()
+    public Set<K> keySet()
     {
       if (keys == null)
         keys = singleton(k);
@@ -1643,7 +1648,7 @@
      * Return the values. Technically, a singleton, while more specific than
      * a general Collection, will work. Besides, that's what the JDK uses!
      */
-    public Collection values()
+    public Collection<V> values()
     {
       if (values == null)
         values = singleton(v);
@@ -1673,7 +1678,7 @@
    * @throws NullPointerException if some element is null
    * @see Arrays#sort(Object[])
    */
-  public static void sort(List l)
+  <T extends Comparable<? super T>> public static void sort(List<T> l)
   {
     sort(l, null);
   }
@@ -1695,11 +1700,11 @@
    *        (only possible when c is null)
    * @see Arrays#sort(Object[], Comparator)
    */
-  public static void sort(List l, Comparator c)
+  <T> public static void sort(List<T> l, Comparator<? super T> c)
   {
     Object[] a = l.toArray();
     Arrays.sort(a, c);
-    ListIterator i = l.listIterator(a.length);
+    ListIterator<T> i = l.listIterator(a.length);
     for (int pos = a.length; --pos >= 0; )
       {
        i.previous();
@@ -1719,7 +1724,7 @@
    *         list.size()
    * @since 1.4
    */
-  public static void swap(List l, int i, int j)
+  public static void swap(List<?> l, int i, int j)
   {
     l.set(i, l.set(j, l.get(i)));
   }
@@ -1752,9 +1757,9 @@
    * @return a synchronized view of the collection
    * @see Serializable
    */
-  public static Collection synchronizedCollection(Collection c)
+  <T> public static Collection<T> synchronizedCollection(Collection<T> c)
   {
-    return new SynchronizedCollection(c);
+    return new SynchronizedCollection<T>(c);
   }
 
   /**
@@ -1765,8 +1770,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  static class SynchronizedCollection
-    implements Collection, Serializable
+  static class SynchronizedCollection<T>
+    implements Collection<T>, Serializable
   {
     /**
      * Compatible with JDK 1.4.
@@ -1777,7 +1782,7 @@
      * The wrapped collection. Package visible for use by subclasses.
      * @serial the real collection
      */
-    final Collection c;
+    final Collection<T> c;
 
     /**
      * The object to synchronize on.  When an instance is created via public
@@ -1792,7 +1797,7 @@
      * @param c the collection to wrap
      * @throws NullPointerException if c is null
      */
-    SynchronizedCollection(Collection c)
+    SynchronizedCollection(Collection<T> c)
     {
       this.c = c;
       mutex = this;
@@ -1806,13 +1811,13 @@
      * @param sync the mutex
      * @param c the collection
      */
-    SynchronizedCollection(Object sync, Collection c)
+    SynchronizedCollection(Object sync, Collection<T> c)
     {
       this.c = c;
       mutex = sync;
     }
 
-    public boolean add(Object o)
+    public boolean add(T o)
     {
       synchronized (mutex)
         {
@@ -1820,7 +1825,7 @@
         }
     }
 
-    public boolean addAll(Collection col)
+    public boolean addAll(Collection<? extends T> col)
     {
       synchronized (mutex)
         {
@@ -1860,7 +1865,7 @@
         }
     }
 
-    public Iterator iterator()
+    public Iterator<T> iterator()
     {
       synchronized (mutex)
         {
@@ -1876,7 +1881,7 @@
         }
     }
 
-    public boolean removeAll(Collection col)
+    public boolean removeAll(Collection<?> col)
     {
       synchronized (mutex)
         {
@@ -1884,7 +1889,7 @@
         }
     }
 
-    public boolean retainAll(Collection col)
+    public boolean retainAll(Collection<?> col)
     {
       synchronized (mutex)
         {
@@ -1908,7 +1913,7 @@
         }
     }
 
-    public Object[] toArray(Object[] a)
+    <T> public T[] toArray(T[] a)
     {
       synchronized (mutex)
         {
@@ -1932,7 +1937,7 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static class SynchronizedIterator implements Iterator
+  private static class SynchronizedIterator<T> implements Iterator<T>
   {
     /**
      * The object to synchronize on. Package visible for use by subclass.
@@ -1942,20 +1947,20 @@
     /**
      * The wrapped iterator.
      */
-    private final Iterator i;
+    private final Iterator<T> i;
 
     /**
      * Only trusted code creates a wrapper, with the specified sync.
      * @param sync the mutex
      * @param i the wrapped iterator
      */
-    SynchronizedIterator(Object sync, Iterator i)
+    SynchronizedIterator(Object sync, Iterator<T> i)
     {
       this.i = i;
       mutex = sync;
     }
 
-    public Object next()
+    public T next()
     {
       synchronized (mutex)
         {
@@ -2006,11 +2011,11 @@
    * @see Serializable
    * @see RandomAccess
    */
-  public static List synchronizedList(List l)
+  <T> public static List<T> synchronizedList(List<T> l)
   {
     if (l instanceof RandomAccess)
-      return new SynchronizedRandomAccessList(l);
-    return new SynchronizedList(l);
+      return new SynchronizedRandomAccessList<T>(l);
+    return new SynchronizedList<T>(l);
   }
 
   /**
@@ -2021,8 +2026,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  static class SynchronizedList extends SynchronizedCollection
-    implements List
+  static class SynchronizedList<T> extends SynchronizedCollection<T>
+    implements List<T>
   {
     /**
      * Compatible with JDK 1.4.
@@ -2034,14 +2039,14 @@
      * excessive casting. Package visible for use by subclass.
      * @serial the wrapped list
      */
-    final List list;
+    final List<T> list;
 
     /**
      * Wrap a given list.
      * @param l the list to wrap
      * @throws NullPointerException if l is null
      */
-    SynchronizedList(List l)
+    SynchronizedList(List<T> l)
     {
       super(l);
       list = l;
@@ -2052,13 +2057,13 @@
      * @param sync the mutex
      * @param l the list
      */
-    SynchronizedList(Object sync, List l)
+    SynchronizedList(Object sync, List<T> l)
     {
       super(sync, l);
       list = l;
     }
 
-    public void add(int index, Object o)
+    public void add(int index, T o)
     {
       synchronized (mutex)
         {
@@ -2066,7 +2071,7 @@
         }
     }
 
-    public boolean addAll(int index, Collection c)
+    public boolean addAll(int index, Collection<? extends T> c)
     {
       synchronized (mutex)
         {
@@ -2082,7 +2087,7 @@
         }
     }
 
-    public Object get(int index)
+    public T get(int index)
     {
       synchronized (mutex)
         {
@@ -2114,7 +2119,7 @@
         }
     }
 
-    public ListIterator listIterator()
+    public ListIterator<T> listIterator()
     {
       synchronized (mutex)
         {
@@ -2122,7 +2127,7 @@
         }
     }
 
-    public ListIterator listIterator(int index)
+    public ListIterator<T> listIterator(int index)
     {
       synchronized (mutex)
         {
@@ -2130,7 +2135,7 @@
         }
     }
 
-    public Object remove(int index)
+    public T remove(int index)
     {
       synchronized (mutex)
         {
@@ -2138,7 +2143,7 @@
         }
     }
 
-    public Object set(int index, Object o)
+    public T set(int index, T o)
     {
       synchronized (mutex)
         {
@@ -2146,7 +2151,7 @@
         }
     }
 
-    public List subList(int fromIndex, int toIndex)
+    public List<T> subList(int fromIndex, int toIndex)
     {
       synchronized (mutex)
         {
@@ -2162,8 +2167,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class SynchronizedRandomAccessList
-    extends SynchronizedList implements RandomAccess
+  private static final class SynchronizedRandomAccessList<T>
+    extends SynchronizedList<T> implements RandomAccess
   {
     /**
      * Compatible with JDK 1.4.
@@ -2175,7 +2180,7 @@
      * @param l the list to wrap
      * @throws NullPointerException if l is null
      */
-    SynchronizedRandomAccessList(List l)
+    SynchronizedRandomAccessList(List<T> l)
     {
       super(l);
     }
@@ -2186,18 +2191,18 @@
      * @param sync the mutex
      * @param l the list
      */
-    SynchronizedRandomAccessList(Object sync, List l)
+    SynchronizedRandomAccessList(Object sync, List<T> l)
     {
       super(sync, l);
     }
 
-    public List subList(int fromIndex, int toIndex)
+    public List<T> subList(int fromIndex, int toIndex)
     {
       synchronized (mutex)
         {
-          return new SynchronizedRandomAccessList(mutex,
-                                                  list.subList(fromIndex,
-                                                               toIndex));
+          return new SynchronizedRandomAccessList<T>(mutex,
+                                                    list.subList(fromIndex,
+                                                                 toIndex));
         }
     }
   } // class SynchronizedRandomAccessList
@@ -2208,33 +2213,34 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class SynchronizedListIterator
-    extends SynchronizedIterator implements ListIterator
+  private static final class SynchronizedListIterator<T>
+    extends SynchronizedIterator<T> implements ListIterator<T>
   {
     /**
      * The wrapped iterator, stored both here and in the superclass to
      * avoid excessive casting.
      */
-    private final ListIterator li;
+    private final ListIterator<T> li;
 
     /**
      * Only trusted code creates a wrapper, with the specified sync.
      * @param sync the mutex
      * @param li the wrapped iterator
      */
-    SynchronizedListIterator(Object sync, ListIterator li)
+    SynchronizedListIterator(Object sync, ListIterator<T> li)
     {
       super(sync, li);
       this.li = li;
     }
 
-    public void add(Object o)
+    public void add(T o)
     {
       synchronized (mutex)
         {
           li.add(o);
         }
     }
+
     public boolean hasPrevious()
     {
       synchronized (mutex)
@@ -2251,7 +2257,7 @@
         }
     }
 
-    public Object previous()
+    public T previous()
     {
       synchronized (mutex)
         {
@@ -2267,7 +2273,7 @@
         }
     }
 
-    public void set(Object o)
+    public void set(T o)
     {
       synchronized (mutex)
         {
@@ -2301,9 +2307,9 @@
    * @return a synchronized view of the map
    * @see Serializable
    */
-  public static Map synchronizedMap(Map m)
+  <K, V> public static Map<K, V> synchronizedMap(Map<K, V> m)
   {
-    return new SynchronizedMap(m);
+    return new SynchronizedMap<K, V>(m);
   }
 
   /**
@@ -2312,7 +2318,7 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static class SynchronizedMap implements Map, Serializable
+  private static class SynchronizedMap<K, V> implements Map<K, V>, Serializable
   {
     /**
      * Compatible with JDK 1.4.
@@ -2323,7 +2329,7 @@
      * The wrapped map.
      * @serial the real map
      */
-    private final Map m;
+    private final Map<K, V> m;
 
     /**
      * The object to synchronize on.  When an instance is created via public
@@ -2337,24 +2343,24 @@
     /**
      * Cache the entry set.
      */
-    private transient Set entries;
+    private transient Set<Map.Entry<K, V>> entries;
 
     /**
      * Cache the key set.
      */
-    private transient Set keys;
+    private transient Set<K> keys;
 
     /**
      * Cache the value collection.
      */
-    private transient Collection values;
+    private transient Collection<V> values;
 
     /**
      * Wrap a given map.
      * @param m the map to wrap
      * @throws NullPointerException if m is null
      */
-    SynchronizedMap(Map m)
+    SynchronizedMap(Map<K, V> m)
     {
       this.m = m;
       mutex = this;
@@ -2367,7 +2373,7 @@
      * @param sync the mutex
      * @param m the map
      */
-    SynchronizedMap(Object sync, Map m)
+    SynchronizedMap(Object sync, Map<K, V> m)
     {
       this.m = m;
       mutex = sync;
@@ -2401,15 +2407,15 @@
     // means "return a SynchronizedSet, except that the iterator() method
     // returns an SynchronizedIterator whose next() method returns a
     // synchronized wrapper around its normal return value".
-    public Set entrySet()
+    public Set<Map.Entry<K, V>> entrySet()
     {
       // Define this here to spare some nesting.
-      class SynchronizedMapEntry implements Map.Entry
+      class SynchronizedMapEntry<K, V> implements Map.Entry<K, V>
       {
-        final Map.Entry e;
-        SynchronizedMapEntry(Object o)
+        final Map.Entry<K, V> e;
+        SynchronizedMapEntry(Map.Entry<K, V> o)
         {
-          e = (Map.Entry) o;
+          e = o;
         }
         public boolean equals(Object o)
         {
@@ -2418,14 +2424,14 @@
               return e.equals(o);
             }
         }
-        public Object getKey()
+        public K getKey()
         {
           synchronized (mutex)
             {
               return e.getKey();
             }
         }
-        public Object getValue()
+        public V getValue()
         {
           synchronized (mutex)
             {
@@ -2439,7 +2445,7 @@
               return e.hashCode();
             }
         }
-        public Object setValue(Object value)
+        public V setValue(V value)
         {
           synchronized (mutex)
             {
@@ -2459,19 +2465,20 @@
       if (entries == null)
         synchronized (mutex)
           {
-            entries = new SynchronizedSet(mutex, m.entrySet())
+            entries = new SynchronizedSet<K, V>(mutex, m.entrySet())
             {
-              public Iterator iterator()
+              public Iterator<Map.Entry<K, V>> iterator()
               {
                 synchronized (super.mutex)
                   {
-                    return new SynchronizedIterator(super.mutex, c.iterator())
+                    return new SynchronizedIterator<K, V>(super.mutex,
+                                                         c.iterator())
                     {
-                      public Object next()
+                      public Map.Entry<K, V> next()
                       {
                         synchronized (super.mutex)
                           {
-                            return new SynchronizedMapEntry(super.next());
+                            return new SynchronizedMapEntry<K, 
V>(super.next());
                           }
                       }
                     };
@@ -2490,7 +2497,7 @@
         }
     }
 
-    public Object get(Object key)
+    public V get(K key)
     {
       synchronized (mutex)
         {
@@ -2514,7 +2521,7 @@
         }
     }
 
-    public Set keySet()
+    public Set<K> keySet()
     {
       if (keys == null)
         synchronized (mutex)
@@ -2524,7 +2531,7 @@
       return keys;
     }
 
-    public Object put(Object key, Object value)
+    public V put(K key, V value)
     {
       synchronized (mutex)
         {
@@ -2532,7 +2539,7 @@
         }
     }
 
-    public void putAll(Map map)
+    public void putAll(Map<K, V> map)
     {
       synchronized (mutex)
         {
@@ -2540,7 +2547,7 @@
         }
     }
 
-    public Object remove(Object o)
+    public V remove(Object o)
     {
       synchronized (mutex)
         {
@@ -2564,7 +2571,7 @@
         }
     }
 
-    public Collection values()
+    public Collection<V> values()
     {
       if (values == null)
         synchronized (mutex)
@@ -2599,9 +2606,9 @@
    * @return a synchronized view of the set
    * @see Serializable
    */
-  public static Set synchronizedSet(Set s)
+  <T> public static Set<T> synchronizedSet(Set<T> s)
   {
-    return new SynchronizedSet(s);
+    return new SynchronizedSet<T>(s);
   }
 
   /**
@@ -2612,8 +2619,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  static class SynchronizedSet extends SynchronizedCollection
-    implements Set
+  static class SynchronizedSet<T> extends SynchronizedCollection<T>
+    implements Set<T>
   {
     /**
      * Compatible with JDK 1.4.
@@ -2625,7 +2632,7 @@
      * @param s the set to wrap
      * @throws NullPointerException if s is null
      */
-    SynchronizedSet(Set s)
+    SynchronizedSet(Set<T> s)
     {
       super(s);
     }
@@ -2635,7 +2642,7 @@
      * @param sync the mutex
      * @param s the set
      */
-    SynchronizedSet(Object sync, Set s)
+    SynchronizedSet(Object sync, Set<T> s)
     {
       super(sync, s);
     }
@@ -2687,9 +2694,9 @@
    * @return a synchronized view of the sorted map
    * @see Serializable
    */
-  public static SortedMap synchronizedSortedMap(SortedMap m)
+  <K, V> public static SortedMap<K, V> synchronizedSortedMap(SortedMap<K, V> m)
   {
-    return new SynchronizedSortedMap(m);
+    return new SynchronizedSortedMap<K, V>(m);
   }
 
   /**
@@ -2698,8 +2705,9 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class SynchronizedSortedMap extends SynchronizedMap
-    implements SortedMap
+  private static final class SynchronizedSortedMap<K, V>
+    extends SynchronizedMap<K, V>
+    implements SortedMap<K, V>
   {
     /**
      * Compatible with JDK 1.4.
@@ -2711,14 +2719,14 @@
      * excessive casting.
      * @serial the wrapped map
      */
-    private final SortedMap sm;
+    private final SortedMap<K, V> sm;
 
     /**
      * Wrap a given map.
      * @param sm the map to wrap
      * @throws NullPointerException if sm is null
      */
-    SynchronizedSortedMap(SortedMap sm)
+    SynchronizedSortedMap(SortedMap<K, V> sm)
     {
       super(sm);
       this.sm = sm;
@@ -2729,13 +2737,13 @@
      * @param sync the mutex
      * @param sm the map
      */
-    SynchronizedSortedMap(Object sync, SortedMap sm)
+    SynchronizedSortedMap(Object sync, SortedMap<K, V> sm)
     {
       super(sync, sm);
       this.sm = sm;
     }
 
-    public Comparator comparator()
+    public Comparator<? super K> comparator()
     {
       synchronized (mutex)
         {
@@ -2743,7 +2751,7 @@
         }
     }
 
-    public Object firstKey()
+    public K firstKey()
     {
       synchronized (mutex)
         {
@@ -2751,15 +2759,15 @@
         }
     }
 
-    public SortedMap headMap(Object toKey)
+    public SortedMap<K, V> headMap(K toKey)
     {
       synchronized (mutex)
         {
-          return new SynchronizedSortedMap(mutex, sm.headMap(toKey));
+          return new SynchronizedSortedMap<K, V>(mutex, sm.headMap(toKey));
         }
     }
 
-    public Object lastKey()
+    public K lastKey()
     {
       synchronized (mutex)
         {
@@ -2767,19 +2775,20 @@
         }
     }
 
-    public SortedMap subMap(Object fromKey, Object toKey)
+    public SortedMap<K, V> subMap(K fromKey, K toKey)
     {
       synchronized (mutex)
         {
-          return new SynchronizedSortedMap(mutex, sm.subMap(fromKey, toKey));
+          return new SynchronizedSortedMap<K, V>(mutex,
+                                                sm.subMap(fromKey, toKey));
         }
     }
 
-    public SortedMap tailMap(Object fromKey)
+    public SortedMap<K, V> tailMap(K fromKey)
     {
       synchronized (mutex)
         {
-          return new SynchronizedSortedMap(mutex, sm.tailMap(fromKey));
+          return new SynchronizedSortedMap<K, V>(mutex, sm.tailMap(fromKey));
         }
     }
   } // class SynchronizedSortedMap
@@ -2809,9 +2818,9 @@
    * @return a synchronized view of the sorted set
    * @see Serializable
    */
-  public static SortedSet synchronizedSortedSet(SortedSet s)
+  public static SortedSet<T> synchronizedSortedSet(SortedSet<T> s)
   {
-    return new SynchronizedSortedSet(s);
+    return new SynchronizedSortedSet<T>(s);
   }
 
   /**
@@ -2820,8 +2829,9 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class SynchronizedSortedSet extends SynchronizedSet
-    implements SortedSet
+  private static final class SynchronizedSortedSet<T>
+    extends SynchronizedSet<T>
+    implements SortedSet<T>
   {
     /**
      * Compatible with JDK 1.4.
@@ -2833,14 +2843,14 @@
      * excessive casting.
      * @serial the wrapped set
      */
-    private final SortedSet ss;
+    private final SortedSet<T> ss;
 
     /**
      * Wrap a given set.
      * @param ss the set to wrap
      * @throws NullPointerException if ss is null
      */
-    SynchronizedSortedSet(SortedSet ss)
+    SynchronizedSortedSet(SortedSet<T> ss)
     {
       super(ss);
       this.ss = ss;
@@ -2851,13 +2861,13 @@
      * @param sync the mutex
      * @param l the list
      */
-    SynchronizedSortedSet(Object sync, SortedSet ss)
+    SynchronizedSortedSet(Object sync, SortedSet<T> ss)
     {
       super(sync, ss);
       this.ss = ss;
     }
 
-    public Comparator comparator()
+    public Comparator<? super T> comparator()
     {
       synchronized (mutex)
         {
@@ -2865,7 +2875,7 @@
         }
     }
 
-    public Object first()
+    public T first()
     {
       synchronized (mutex)
         {
@@ -2873,15 +2883,15 @@
         }
     }
 
-    public SortedSet headSet(Object toElement)
+    public SortedSet<T> headSet(T toElement)
     {
       synchronized (mutex)
         {
-          return new SynchronizedSortedSet(mutex, ss.headSet(toElement));
+          return new SynchronizedSortedSet<T>(mutex, ss.headSet(toElement));
         }
     }
 
-    public Object last()
+    public T last()
     {
       synchronized (mutex)
         {
@@ -2889,20 +2899,21 @@
         }
     }
 
-    public SortedSet subSet(Object fromElement, Object toElement)
+    public SortedSet<T> subSet(T fromElement, T toElement)
     {
       synchronized (mutex)
         {
-          return new SynchronizedSortedSet(mutex,
-                                           ss.subSet(fromElement, toElement));
+          return new SynchronizedSortedSet<T>(mutex,
+                                             ss.subSet(fromElement,
+                                                       toElement));
         }
     }
 
-    public SortedSet tailSet(Object fromElement)
+    public SortedSet<T> tailSet(T fromElement)
     {
       synchronized (mutex)
         {
-          return new SynchronizedSortedSet(mutex, ss.tailSet(fromElement));
+          return new SynchronizedSortedSet<T>(mutex, ss.tailSet(fromElement));
         }
     }
   } // class SynchronizedSortedSet
@@ -2925,9 +2936,9 @@
    * @return a read-only view of the collection
    * @see Serializable
    */
-  public static Collection unmodifiableCollection(Collection c)
+  <T> public static Collection<T> unmodifiableCollection(Collection<T> c)
   {
-    return new UnmodifiableCollection(c);
+    return new UnmodifiableCollection<T>(c);
   }
 
   /**
@@ -2936,8 +2947,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static class UnmodifiableCollection
-    implements Collection, Serializable
+  private static class UnmodifiableCollection<T>
+    implements Collection<T>, Serializable
   {
     /**
      * Compatible with JDK 1.4.
@@ -2948,26 +2959,26 @@
      * The wrapped collection. Package visible for use by subclasses.
      * @serial the real collection
      */
-    final Collection c;
+    final Collection<T> c;
 
     /**
      * Wrap a given collection.
      * @param c the collection to wrap
      * @throws NullPointerException if c is null
      */
-    UnmodifiableCollection(Collection c)
+    UnmodifiableCollection(Collection<T> c)
     {
       this.c = c;
       if (c == null)
         throw new NullPointerException();
     }
 
-    public boolean add(Object o)
+    public boolean add(T o)
     {
       throw new UnsupportedOperationException();
     }
 
-    public boolean addAll(Collection c)
+    public boolean addAll(Collection<? extends T> c)
     {
       throw new UnsupportedOperationException();
     }
@@ -2992,9 +3003,9 @@
       return c.isEmpty();
     }
 
-    public Iterator iterator()
+    public Iterator<T> iterator()
     {
-      return new UnmodifiableIterator(c.iterator());
+      return new UnmodifiableIterator<T>(c.iterator());
     }
 
     public boolean remove(Object o)
@@ -3002,12 +3013,12 @@
       throw new UnsupportedOperationException();
     }
 
-    public boolean removeAll(Collection c)
+    public boolean removeAll(Collection<?> c)
     {
       throw new UnsupportedOperationException();
     }
 
-    public boolean retainAll(Collection c)
+    public boolean retainAll(Collection<?> c)
     {
       throw new UnsupportedOperationException();
     }
@@ -3022,7 +3033,7 @@
       return c.toArray();
     }
 
-    public Object[] toArray(Object[] a)
+    <S> public S[] toArray(S[] a)
     {
       return c.toArray(a);
     }
@@ -3039,23 +3050,23 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static class UnmodifiableIterator implements Iterator
+  private static class UnmodifiableIterator<T> implements Iterator<T>
   {
     /**
      * The wrapped iterator.
      */
-    private final Iterator i;
+    private final Iterator<T> i;
 
     /**
      * Only trusted code creates a wrapper.
      * @param i the wrapped iterator
      */
-    UnmodifiableIterator(Iterator i)
+    UnmodifiableIterator(Iterator<T> i)
     {
       this.i = i;
     }
 
-    public Object next()
+    public T next()
     {
       return i.next();
     }
@@ -3087,11 +3098,11 @@
    * @see Serializable
    * @see RandomAccess
    */
-  public static List unmodifiableList(List l)
+  <T> public static List<T> unmodifiableList(List<T> l)
   {
     if (l instanceof RandomAccess)
-      return new UnmodifiableRandomAccessList(l);
-    return new UnmodifiableList(l);
+      return new UnmodifiableRandomAccessList<T>(l);
+    return new UnmodifiableList<T>(l);
   }
 
   /**
@@ -3101,8 +3112,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static class UnmodifiableList extends UnmodifiableCollection
-    implements List
+  private static class UnmodifiableList<T> extends UnmodifiableCollection<T>
+    implements List<T>
   {
     /**
      * Compatible with JDK 1.4.
@@ -3115,25 +3126,25 @@
      * excessive casting. Package visible for use by subclass.
      * @serial the wrapped list
      */
-    final List list;
+    final List<T> list;
 
     /**
      * Wrap a given list.
      * @param l the list to wrap
      * @throws NullPointerException if l is null
      */
-    UnmodifiableList(List l)
+    UnmodifiableList(List<T> l)
     {
       super(l);
       list = l;
     }
 
-    public void add(int index, Object o)
+    public void add(int index, T o)
     {
       throw new UnsupportedOperationException();
     }
 
-    public boolean addAll(int index, Collection c)
+    public boolean addAll(int index, Collection<? extends T> c)
     {
       throw new UnsupportedOperationException();
     }
@@ -3143,7 +3154,7 @@
       return list.equals(o);
     }
 
-    public Object get(int index)
+    public T get(int index)
     {
       return list.get(index);
     }
@@ -3163,27 +3174,27 @@
       return list.lastIndexOf(o);
     }
 
-    public ListIterator listIterator()
+    public ListIterator<T> listIterator()
     {
       return new UnmodifiableListIterator(list.listIterator());
     }
 
-    public ListIterator listIterator(int index)
+    public ListIterator<T> listIterator(int index)
     {
       return new UnmodifiableListIterator(list.listIterator(index));
     }
 
-    public Object remove(int index)
+    public T remove(int index)
     {
       throw new UnsupportedOperationException();
     }
 
-    public Object set(int index, Object o)
+    public T set(int index, T o)
     {
       throw new UnsupportedOperationException();
     }
 
-    public List subList(int fromIndex, int toIndex)
+    public List<T> subList(int fromIndex, int toIndex)
     {
       return unmodifiableList(list.subList(fromIndex, toIndex));
     }
@@ -3196,8 +3207,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class UnmodifiableRandomAccessList
-    extends UnmodifiableList implements RandomAccess
+  private static final class UnmodifiableRandomAccessList<T>
+    extends UnmodifiableList<T> implements RandomAccess
   {
     /**
      * Compatible with JDK 1.4.
@@ -3209,7 +3220,7 @@
      * @param l the list to wrap
      * @throws NullPointerException if l is null
      */
-    UnmodifiableRandomAccessList(List l)
+    UnmodifiableRandomAccessList(List<T> l)
     {
       super(l);
     }
@@ -3220,26 +3231,26 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static final class UnmodifiableListIterator
-    extends UnmodifiableIterator implements ListIterator
+  private static final class UnmodifiableListIterator<T>
+    extends UnmodifiableIterator<T> implements ListIterator<T>
   {
     /**
      * The wrapped iterator, stored both here and in the superclass to
      * avoid excessive casting.
      */
-    private final ListIterator li;
+    private final ListIterator<T> li;
 
     /**
      * Only trusted code creates a wrapper.
      * @param li the wrapped iterator
      */
-    UnmodifiableListIterator(ListIterator li)
+    UnmodifiableListIterator(ListIterator<T> li)
     {
       super(li);
       this.li = li;
     }
 
-    public void add(Object o)
+    public void add(T o)
     {
       throw new UnsupportedOperationException();
     }
@@ -3254,7 +3265,7 @@
       return li.nextIndex();
     }
 
-    public Object previous()
+    public T previous()
     {
       return li.previous();
     }
@@ -3264,7 +3275,7 @@
       return li.previousIndex();
     }
 
-    public void set(Object o)
+    public void set(T o)
     {
       throw new UnsupportedOperationException();
     }
@@ -3284,9 +3295,9 @@
    * @return a read-only view of the map
    * @see Serializable
    */
-  public static Map unmodifiableMap(Map m)
+  <K, V> public static Map<K, V> unmodifiableMap(Map<K, V> m)
   {
-    return new UnmodifiableMap(m);
+    return new UnmodifiableMap<K, V>(m);
   }
 
   /**
@@ -3295,7 +3306,7 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static class UnmodifiableMap implements Map, Serializable
+  private static class UnmodifiableMap<K, V> implements Map<K, V>, Serializable
   {
     /**
      * Compatible with JDK 1.4.
@@ -3306,29 +3317,30 @@
      * The wrapped map.
      * @serial the real map
      */
-    private final Map m;
+    private final Map<K, V> m;
 
     /**
      * Cache the entry set.
      */
-    private transient Set entries;
+    // fixme Set<? extends Entry<K, V>> ?
+    private transient Set<Map.Entry<K, V>> entries;
 
     /**
      * Cache the key set.
      */
-    private transient Set keys;
+    private transient Set<K> keys;
 
     /**
      * Cache the value collection.
      */
-    private transient Collection values;
+    private transient Collection<V> values;
 
     /**
      * Wrap a given map.
      * @param m the map to wrap
      * @throws NullPointerException if m is null
      */
-    UnmodifiableMap(Map m)
+    UnmodifiableMap(Map<K, V> m)
     {
       this.m = m;
       if (m == null)
@@ -3350,10 +3362,10 @@
       return m.containsValue(value);
     }
 
-    public Set entrySet()
+    public Set<Map.Entry<K, V>> entrySet()
     {
       if (entries == null)
-        entries = new UnmodifiableEntrySet(m.entrySet());
+        entries = new UnmodifiableEntrySet<Map.Entry<K, V>>(m.entrySet());
       return entries;
     }
 
@@ -3363,7 +3375,8 @@
      *
      * @author Eric Blake <address@hidden>
      */
-    private static final class UnmodifiableEntrySet extends UnmodifiableSet
+    private static final class UnmodifiableEntrySet<T extends Map.Entry<K, V>>
+      extends UnmodifiableSet<T>
       implements Serializable
     {
       /**
@@ -3375,30 +3388,30 @@
        * Wrap a given set.
        * @param s the set to wrap
        */
-      UnmodifiableEntrySet(Set s)
+      UnmodifiableEntrySet(Set<T> s)
       {
         super(s);
       }
 
       // The iterator must return unmodifiable map entries.
-      public Iterator iterator()
+      public Iterator<T> iterator()
       {
-        return new UnmodifiableIterator(c.iterator())
+        return new UnmodifiableIterator<T>(c.iterator())
        {
           public Object next()
           {
-            final Map.Entry e = (Map.Entry) super.next();
-            return new Map.Entry()
+            final T e = super.next();
+            return new Map.Entry<K, V>()
            {
               public boolean equals(Object o)
               {
                 return e.equals(o);
               }
-              public Object getKey()
+              public K getKey()
               {
                 return e.getKey();
               }
-              public Object getValue()
+              public V getValue()
               {
                 return e.getValue();
               }
@@ -3406,7 +3419,7 @@
               {
                 return e.hashCode();
               }
-              public Object setValue(Object value)
+              public V setValue(V value)
               {
                 throw new UnsupportedOperationException();
               }
@@ -3425,12 +3438,12 @@
       return m.equals(o);
     }
 
-    public Object get(Object key)
+    public V get(K key)
     {
       return m.get(key);
     }
 
-    public Object put(Object key, Object value)
+    public V put(K key, V value)
     {
       throw new UnsupportedOperationException();
     }
@@ -3445,19 +3458,19 @@
       return m.isEmpty();
     }
 
-    public Set keySet()
+    public Set<K> keySet()
     {
       if (keys == null)
-        keys = new UnmodifiableSet(m.keySet());
+        keys = new UnmodifiableSet<K>(m.keySet());
       return keys;
     }
 
-    public void putAll(Map m)
+    public void putAll(Map<K, V> m)
     {
       throw new UnsupportedOperationException();
     }
 
-    public Object remove(Object o)
+    public Map.Entry<K, V> remove(Object o)
     {
       throw new UnsupportedOperationException();
     }
@@ -3472,10 +3485,10 @@
       return m.toString();
     }
 
-    public Collection values()
+    public Collection<V> values()
     {
       if (values == null)
-        values = new UnmodifiableCollection(m.values());
+        values = new UnmodifiableCollection<V>(m.values());
       return values;
     }
   } // class UnmodifiableMap
@@ -3494,9 +3507,9 @@
    * @return a read-only view of the set
    * @see Serializable
    */
-  public static Set unmodifiableSet(Set s)
+  <T> public static Set<T> unmodifiableSet(Set<T> s)
   {
-    return new UnmodifiableSet(s);
+    return new UnmodifiableSet<T>(s);
   }
 
   /**
@@ -3505,8 +3518,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static class UnmodifiableSet extends UnmodifiableCollection
-    implements Set
+  private static class UnmodifiableSet<T> extends UnmodifiableCollection<T>
+    implements Set<T>
   {
     /**
      * Compatible with JDK 1.4.
@@ -3518,7 +3531,7 @@
      * @param s the set to wrap
      * @throws NullPointerException if s is null
      */
-    UnmodifiableSet(Set s)
+    UnmodifiableSet(Set<T> s)
     {
       super(s);
     }
@@ -3548,9 +3561,9 @@
    * @return a read-only view of the map
    * @see Serializable
    */
-  public static SortedMap unmodifiableSortedMap(SortedMap m)
+  <K, V> public static SortedMap<K, V> unmodifiableSortedMap(SortedMap<K, V> m)
   {
-    return new UnmodifiableSortedMap(m);
+    return new UnmodifiableSortedMap<K, V>(m);
   }
 
   /**
@@ -3559,8 +3572,9 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static class UnmodifiableSortedMap extends UnmodifiableMap
-    implements SortedMap
+  private static class UnmodifiableSortedMap<K, V>
+    extends UnmodifiableMap<K, V>
+    implements SortedMap<K, V>
   {
     /**
      * Compatible with JDK 1.4.
@@ -3572,47 +3586,47 @@
      * excessive casting.
      * @serial the wrapped map
      */
-    private final SortedMap sm;
+    private final SortedMap<K, V> sm;
 
     /**
      * Wrap a given map.
      * @param sm the map to wrap
      * @throws NullPointerException if sm is null
      */
-    UnmodifiableSortedMap(SortedMap sm)
+    UnmodifiableSortedMap(SortedMap<K, V> sm)
     {
       super(sm);
       this.sm = sm;
     }
 
-    public Comparator comparator()
+    public Comparator<? super K> comparator()
     {
       return sm.comparator();
     }
 
-    public Object firstKey()
+    public K firstKey()
     {
       return sm.firstKey();
     }
 
-    public SortedMap headMap(Object toKey)
+    public SortedMap<K, V> headMap(K toKey)
     {
-      return new UnmodifiableSortedMap(sm.headMap(toKey));
+      return new UnmodifiableSortedMap<K, V>(sm.headMap(toKey));
     }
 
-    public Object lastKey()
+    public K lastKey()
     {
       return sm.lastKey();
     }
 
-    public SortedMap subMap(Object fromKey, Object toKey)
+    public SortedMap<K, V> subMap(K fromKey, K toKey)
     {
-      return new UnmodifiableSortedMap(sm.subMap(fromKey, toKey));
+      return new UnmodifiableSortedMap<K, V>(sm.subMap(fromKey, toKey));
     }
 
-    public SortedMap tailMap(Object fromKey)
+    public SortedMap<K, V> tailMap(K fromKey)
     {
-      return new UnmodifiableSortedMap(sm.tailMap(fromKey));
+      return new UnmodifiableSortedMap<K, V>(sm.tailMap(fromKey));
     }
   } // class UnmodifiableSortedMap
 
@@ -3630,9 +3644,9 @@
    * @return a read-only view of the set
    * @see Serializable
    */
-  public static SortedSet unmodifiableSortedSet(SortedSet s)
+  <T> public static SortedSet<T> unmodifiableSortedSet(SortedSet<T> s)
   {
-    return new UnmodifiableSortedSet(s);
+    return new UnmodifiableSortedSet<T>(s);
   }
 
   /**
@@ -3641,8 +3655,8 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  private static class UnmodifiableSortedSet extends UnmodifiableSet
-    implements SortedSet
+  private static class UnmodifiableSortedSet<T> extends UnmodifiableSet<T>
+    implements SortedSet<T>
   {
     /**
      * Compatible with JDK 1.4.
@@ -3654,47 +3668,47 @@
      * excessive casting.
      * @serial the wrapped set
      */
-    private SortedSet ss;
+    private SortedSet<T> ss;
 
     /**
      * Wrap a given set.
      * @param ss the set to wrap
      * @throws NullPointerException if ss is null
      */
-    UnmodifiableSortedSet(SortedSet ss)
+    UnmodifiableSortedSet(SortedSet<T> ss)
     {
       super(ss);
       this.ss = ss;
     }
 
-    public Comparator comparator()
+    public Comparator<? super T> comparator()
     {
       return ss.comparator();
     }
 
-    public Object first()
+    public T first()
     {
       return ss.first();
     }
 
-    public SortedSet headSet(Object toElement)
+    public SortedSet<T> headSet(T toElement)
     {
-      return new UnmodifiableSortedSet(ss.headSet(toElement));
+      return new UnmodifiableSortedSet<T>(ss.headSet(toElement));
     }
 
-    public Object last()
+    public T last()
     {
       return ss.last();
     }
 
-    public SortedSet subSet(Object fromElement, Object toElement)
+    public SortedSet<T> subSet(T fromElement, T toElement)
     {
-      return new UnmodifiableSortedSet(ss.subSet(fromElement, toElement));
+      return new UnmodifiableSortedSet<T>(ss.subSet(fromElement, toElement));
     }
 
-    public SortedSet tailSet(Object fromElement)
+    public SortedSet<T> tailSet(T fromElement)
     {
-      return new UnmodifiableSortedSet(ss.tailSet(fromElement));
+      return new UnmodifiableSortedSet<T>(ss.tailSet(fromElement));
     }
   } // class UnmodifiableSortedSet
 } // class Collections
Index: java/util/Comparator.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Comparator.java,v
retrieving revision 1.7
diff -u -r1.7 Comparator.java
--- java/util/Comparator.java 22 Jan 2002 22:27:01 -0000 1.7
+++ java/util/Comparator.java 5 Aug 2004 20:49:22 -0000
@@ -1,5 +1,5 @@
 /* Comparator.java -- Interface for objects that specify an ordering
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -71,7 +71,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface Comparator
+public interface Comparator<T>
 {
   /**
    * Return an integer that is negative, zero or positive depending on whether
@@ -102,7 +102,7 @@
    * @throws ClassCastException if the elements are not of types that can be
    *         compared by this ordering.
    */
-  int compare(Object o1, Object o2);
+  int compare(T o1, T o2);
 
   /**
    * Return true if the object is equal to this object.  To be
Index: java/util/Dictionary.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Dictionary.java,v
retrieving revision 1.9
diff -u -r1.9 Dictionary.java
--- java/util/Dictionary.java 30 Apr 2002 22:07:41 -0000 1.9
+++ java/util/Dictionary.java 5 Aug 2004 20:49:22 -0000
@@ -1,6 +1,6 @@
 /* Dictionary.java -- an abstract (and essentially worthless) 
    class which is Hashtable's superclass
-   Copyright (C) 1998, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -57,7 +57,7 @@
  * @since 1.0
  * @status updated to 1.4
  */
-public abstract class Dictionary
+public abstract class Dictionary<K, V>
 {
   // WARNING: Dictionary is a CORE class in the bootstrap cycle. See the
   // comments in vm/reference/java/lang/Runtime for implications of this fact.
@@ -75,7 +75,7 @@
    * @return an Enumeration of the values
    * @see #keys()
    */
-  public abstract Enumeration elements();
+  public abstract Enumeration<V> elements();
 
   /** 
    * Returns the value associated with the supplied key, or null
@@ -87,7 +87,7 @@
    * @throws NullPointerException if key is null
    * @see #put(Object, Object)
    */
-  public abstract Object get(Object key);
+  public abstract V get(Object key);
 
   /**
    * Returns true when there are no elements in this Dictionary.
@@ -102,7 +102,7 @@
    * @return an Enumeration of the keys
    * @see #elements()
    */
-  public abstract Enumeration keys();
+  public abstract Enumeration<K> keys();
 
   /**
    * Inserts a new value into this Dictionary, located by the
@@ -115,7 +115,7 @@
    * @throws NullPointerException if key or value is null
    * @see #get(Object)
    */
-  public abstract Object put(Object key, Object value);
+  public abstract V put(K key, V value);
 
   /**
    * Removes from the Dictionary the value located by the given key. A null
@@ -125,7 +125,7 @@
    * @return the value associated with the removed key
    * @throws NullPointerException if key is null
    */
-  public abstract Object remove(Object key);
+  public abstract V remove(K key);
 
   /**
    * Returns the number of values currently in this Dictionary.
Index: java/util/Enumeration.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Enumeration.java,v
retrieving revision 1.7
diff -u -r1.7 Enumeration.java
--- java/util/Enumeration.java 22 Jan 2002 22:27:01 -0000 1.7
+++ java/util/Enumeration.java 5 Aug 2004 20:49:22 -0000
@@ -1,5 +1,5 @@
 /* Enumeration.java -- Interface for enumerating lists of objects
-   Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -60,7 +60,7 @@
  * @since 1.0
  * @status updated to 1.4
  */
-public interface Enumeration
+public interface Enumeration<E>
 {
   /**
    * Tests whether there are elements remaining in the enumeration.
@@ -77,5 +77,5 @@
    * @return the next element in the enumeration
    * @throws NoSuchElementException if there are no more elements
    */
-  Object nextElement();
+  E nextElement();
 }
Index: java/util/HashMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/HashMap.java,v
retrieving revision 1.28
diff -u -r1.28 HashMap.java
--- java/util/HashMap.java 29 Apr 2004 22:49:51 -0000 1.28
+++ java/util/HashMap.java 5 Aug 2004 20:49:23 -0000
@@ -96,8 +96,8 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public class HashMap extends AbstractMap
-  implements Map, Cloneable, Serializable
+public class HashMap<K, V> extends AbstractMap<K, V>
+  implements Map<K, V>, Cloneable, Serializable
 {
   /**
    * Default number of buckets. This is the value the JDK 1.3 uses. Some
@@ -136,7 +136,7 @@
    * Array containing the actual key-value mappings.
    * Package visible for use by nested and subclasses.
    */
-  transient HashEntry[] buckets;
+  transient HashEntry<K, V>[] buckets;
 
   /**
    * Counts the number of modifications this HashMap has undergone, used
@@ -154,7 +154,7 @@
   /**
    * The cache for address@hidden #entrySet()}.
    */
-  private transient Set entries;
+  private transient Set<HashEntry<K, V>> entries;
 
   /**
    * Class to represent an entry in the hash table. Holds a single key-value
@@ -162,19 +162,19 @@
    *
    * @author Eric Blake <address@hidden>
    */
-  static class HashEntry extends AbstractMap.BasicMapEntry
+  static class HashEntry<K, V> extends AbstractMap.BasicMapEntry<K, V>
   {
     /**
      * The next entry in the linked list. Package visible for use by subclass.
      */
-    HashEntry next;
+    HashEntry<K, V> next;
 
     /**
      * Simple constructor.
      * @param key the key
      * @param value the value
      */
-    HashEntry(Object key, Object value)
+    HashEntry(K key, V value)
     {
       super(key, value);
     }
@@ -194,7 +194,7 @@
      *
      * @return the value of this key as it is removed
      */
-    Object cleanup()
+    V cleanup()
     {
       return value;
     }
@@ -220,7 +220,7 @@
    *        <b>NOTE: key / value pairs are not cloned in this constructor.</b>
    * @throws NullPointerException if m is null
    */
-  public HashMap(Map m)
+  public HashMap(Map<? extends K, ? extends V> m)
   {
     this(Math.max(m.size() * 2, DEFAULT_CAPACITY), DEFAULT_LOAD_FACTOR);
     putAll(m);
@@ -292,10 +292,10 @@
    * @see #put(Object, Object)
    * @see #containsKey(Object)
    */
-  public Object get(Object key)
+  public V get(Object key)
   {
     int idx = hash(key);
-    HashEntry e = buckets[idx];
+    HashEntry<K, V> e = buckets[idx];
     while (e != null)
       {
         if (equals(key, e.key))
@@ -316,7 +316,7 @@
   public boolean containsKey(Object key)
   {
     int idx = hash(key);
-    HashEntry e = buckets[idx];
+    HashEntry<K, V> e = buckets[idx];
     while (e != null)
       {
         if (equals(key, e.key))
@@ -339,17 +339,17 @@
    * @see #get(Object)
    * @see Object#equals(Object)
    */
-  public Object put(Object key, Object value)
+  public V put(K key, V value)
   {
     int idx = hash(key);
-    HashEntry e = buckets[idx];
+    HashEntry<K, V> e = buckets[idx];
 
     while (e != null)
       {
         if (equals(key, e.key))
           {
             e.access(); // Must call this for bookkeeping in LinkedHashMap.
-            Object r = e.value;
+           V r = e.value;
             e.value = value;
             return r;
           }
@@ -378,23 +378,24 @@
    *
    * @param m the map to be hashed into this
    */
-  public void putAll(Map m)
+  public void putAll(Map<? extends K, ? extends V> m)
   {
-    Iterator itr = m.entrySet().iterator();
+    Iterator<? extends K, ? extends V> itr = m.entrySet().iterator();
     while (itr.hasNext())
       {
-        Map.Entry e = (Map.Entry) itr.next();
+        Map.Entry<? extends K, ? extends V> e = itr.next();
         // Optimize in case the Entry is one of our own.
         if (e instanceof AbstractMap.BasicMapEntry)
           {
-            AbstractMap.BasicMapEntry entry = (AbstractMap.BasicMapEntry) e;
+            AbstractMap.BasicMapEntry<? extends K, ? extends V> entry
+             = (AbstractMap.BasicMapEntry<? extends K, ? extends V>) e;
             put(entry.key, entry.value);
           }
         else
           put(e.getKey(), e.getValue());
       }
   }
-  
+
   /**
    * Removes from the HashMap and returns the value which is mapped by the
    * supplied key. If the key maps to nothing, then the HashMap remains
@@ -405,11 +406,11 @@
    * @param key the key used to locate the value to remove
    * @return whatever the key mapped to, if present
    */
-  public Object remove(Object key)
+  public V remove(Object key)
   {
     int idx = hash(key);
-    HashEntry e = buckets[idx];
-    HashEntry last = null;
+    HashEntry<K, V> e = buckets[idx];
+    HashEntry<K, V> last = null;
 
     while (e != null)
       {
@@ -499,19 +500,19 @@
    * @see #values()
    * @see #entrySet()
    */
-  public Set keySet()
+  public Set<K> keySet()
   {
     if (keys == null)
       // Create an AbstractSet with custom implementations of those methods
       // that can be overridden easily and efficiently.
-      keys = new AbstractSet()
+      keys = new AbstractSet<K>()
       {
         public int size()
         {
           return size;
         }
 
-        public Iterator iterator()
+        public Iterator<K> iterator()
         {
           // Cannot create the iterator directly, because of LinkedHashMap.
           return HashMap.this.iterator(KEYS);
@@ -550,19 +551,19 @@
    * @see #keySet()
    * @see #entrySet()
    */
-  public Collection values()
+  public Collection<V> values()
   {
     if (values == null)
       // We don't bother overriding many of the optional methods, as doing so
       // wouldn't provide any significant performance advantage.
-      values = new AbstractCollection()
+      values = new AbstractCollection<V>()
       {
         public int size()
         {
           return size;
         }
 
-        public Iterator iterator()
+        public Iterator<V> iterator()
         {
           // Cannot create the iterator directly, because of LinkedHashMap.
           return HashMap.this.iterator(VALUES);
@@ -589,19 +590,19 @@
    * @see #values()
    * @see Map.Entry
    */
-  public Set entrySet()
+  public Set<Map.Entry<K, V>> entrySet()
   {
     if (entries == null)
       // Create an AbstractSet with custom implementations of those methods
       // that can be overridden easily and efficiently.
-      entries = new AbstractSet()
+      entries = new AbstractSet<Map.Entry<K, V>>()
       {
         public int size()
         {
           return size;
         }
 
-        public Iterator iterator()
+        public Iterator<Map.Entry<K, V>> iterator()
         {
           // Cannot create the iterator directly, because of LinkedHashMap.
           return HashMap.this.iterator(ENTRIES);
@@ -619,7 +620,7 @@
 
         public boolean remove(Object o)
         {
-          HashEntry e = getEntry(o);
+          HashEntry<K, V> e = getEntry(o);
           if (e != null)
             {
               HashMap.this.remove(e.key);
@@ -641,9 +642,9 @@
    * @param callRemove whether to call the removeEldestEntry method
    * @see #put(Object, Object)
    */
-  void addEntry(Object key, Object value, int idx, boolean callRemove)
+  void addEntry(K key, V value, int idx, boolean callRemove)
   {
-    HashEntry e = new HashEntry(key, value);
+    HashEntry<K, V> e = new HashEntry<K, V>(key, value);
     e.next = buckets[idx];
     buckets[idx] = e;
   }
@@ -657,14 +658,14 @@
    * @see #entrySet()
    */
   // Package visible, for use in nested classes.
-  final HashEntry getEntry(Object o)
+  final HashEntry<K, V> getEntry(Object o)
   {
     if (! (o instanceof Map.Entry))
       return null;
-    Map.Entry me = (Map.Entry) o;
-    Object key = me.getKey();
+    Map.Entry<K, V> me = (Map.Entry<K, V>) o;
+    K key = me.getKey();
     int idx = hash(key);
-    HashEntry e = buckets[idx];
+    HashEntry<K, V> e = buckets[idx];
     while (e != null)
       {
         if (equals(e.key, key))
@@ -693,9 +694,10 @@
    * @param type address@hidden #KEYS}, address@hidden #VALUES}, or 
address@hidden #ENTRIES}
    * @return the appropriate iterator
    */
-  Iterator iterator(int type)
+  <T> Iterator<T> iterator(int type)
   {
-    return new HashIterator(type);
+    // FIXME: bogus cast here.
+    return new HashIterator<T>(type);
   }
 
   /**
@@ -705,15 +707,15 @@
    *
    * @param m the map to initialize this from
    */
-  void putAllInternal(Map m)
+  void putAllInternal(Map<? extends K, ? extends V> m)
   {
-    Iterator itr = m.entrySet().iterator();
+    Iterator<? extends K, ? extends V> itr = m.entrySet().iterator();
     size = 0;
     while (itr.hasNext())
       {
         size++;
-       Map.Entry e = (Map.Entry) itr.next();
-       Object key = e.getKey();
+       Map.Entry<K, V> e = itr.next();
+       K key = e.getKey();
        int idx = hash(key);
        addEntry(key, e.getValue(), idx, false);
       }
@@ -730,20 +732,20 @@
    */
   private void rehash()
   {
-    HashEntry[] oldBuckets = buckets;
+    HashEntry<K, V>[] oldBuckets = buckets;
 
     int newcapacity = (buckets.length * 2) + 1;
     threshold = (int) (newcapacity * loadFactor);
-    buckets = new HashEntry[newcapacity];
+    buckets = new HashEntry<K, V>[newcapacity];
 
     for (int i = oldBuckets.length - 1; i >= 0; i--)
       {
-        HashEntry e = oldBuckets[i];
+        HashEntry<K, V> e = oldBuckets[i];
         while (e != null)
           {
             int idx = hash(e.key);
-            HashEntry dest = buckets[idx];
-            HashEntry next = e.next;
+            HashEntry<K, V> dest = buckets[idx];
+            HashEntry<K, V> next = e.next;
             e.next = buckets[idx];
             buckets[idx] = e;
             e = next;
@@ -769,10 +771,10 @@
     s.writeInt(buckets.length);
     s.writeInt(size);
     // Avoid creating a wasted Set by creating the iterator directly.
-    Iterator it = iterator(ENTRIES);
+    Iterator<HashEntry<K, V>> it = iterator(ENTRIES);
     while (it.hasNext())
       {
-        HashEntry entry = (HashEntry) it.next();
+        HashEntry<K, V> entry = it.next();
         s.writeObject(entry.key);
         s.writeObject(entry.value);
       }
@@ -796,13 +798,13 @@
     s.defaultReadObject();
 
     // Read and use capacity, followed by key/value pairs.
-    buckets = new HashEntry[s.readInt()];
+    buckets = new HashEntry<K, V>[s.readInt()];
     int len = s.readInt();
     size = len;
     while (len-- > 0)
       {
         Object key = s.readObject();
-        addEntry(key, s.readObject(), hash(key), false);
+        addEntry((K) key, (V) s.readObject(), hash(key), false);
       }
   }
 
Index: java/util/HashSet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/HashSet.java,v
retrieving revision 1.11
diff -u -r1.11 HashSet.java
--- java/util/HashSet.java 22 Apr 2004 11:24:39 -0000 1.11
+++ java/util/HashSet.java 5 Aug 2004 20:49:23 -0000
@@ -76,8 +76,8 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public class HashSet extends AbstractSet
-  implements Set, Cloneable, Serializable
+public class HashSet<T> extends AbstractSet<T>
+  implements Set<T>, Cloneable, Serializable
 {
   /**
    * Compatible with JDK 1.2.
@@ -87,7 +87,7 @@
   /**
    * The HashMap which backs this Set.
    */
-  private transient HashMap map;
+  private transient HashMap<T, String> map;
 
   /**
    * Construct a new, empty HashSet whose backing HashMap has the default
@@ -133,7 +133,7 @@
    * @param c a collection of initial set elements
    * @throws NullPointerException if c is null
    */
-  public HashSet(Collection c)
+  public HashSet(Collection<? extends T> c)
   {
     this(Math.max(2 * c.size(), HashMap.DEFAULT_CAPACITY));
     addAll(c);
@@ -146,7 +146,7 @@
    * @param o the Object to add to this Set
    * @return true if the set did not already contain o
    */
-  public boolean add(Object o)
+  public boolean add(T o)
   {
     return map.put(o, "") == null;
   }
@@ -167,16 +167,16 @@
    */
   public Object clone()
   {
-    HashSet copy = null;
+    HashSet<T> copy = null;
     try
       {
-        copy = (HashSet) super.clone();
+        copy = (HashSet<T>) super.clone();
       }
     catch (CloneNotSupportedException x)
       {
         // Impossible to get here.
       }
-    copy.map = (HashMap) map.clone();
+    copy.map = (HashMap<T, String>) map.clone();
     return copy;
   }
 
@@ -210,7 +210,7 @@
    * @return a set iterator
    * @see ConcurrentModificationException
    */
-  public Iterator iterator()
+  public Iterator<T> iterator()
   {
     // Avoid creating intermediate keySet() object by using non-public API.
     return map.iterator(HashMap.KEYS);
@@ -263,7 +263,7 @@
   {
     s.defaultWriteObject();
     // Avoid creating intermediate keySet() object by using non-public API.
-    Iterator it = map.iterator(HashMap.KEYS);
+    Iterator<T> it = map.iterator(HashMap.KEYS);
     s.writeInt(map.buckets.length);
     s.writeFloat(map.loadFactor);
     s.writeInt(map.size);
@@ -288,6 +288,6 @@
 
     map = init(s.readInt(), s.readFloat());
     for (int size = s.readInt(); size > 0; size--)
-      map.put(s.readObject(), "");
+      map.put((T) s.readObject(), "");
   }
 }
Index: java/util/Iterator.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Iterator.java,v
retrieving revision 1.6
diff -u -r1.6 Iterator.java
--- java/util/Iterator.java 22 Jan 2002 22:27:01 -0000 1.6
+++ java/util/Iterator.java 5 Aug 2004 20:49:23 -0000
@@ -1,5 +1,5 @@
 /* Iterator.java -- Interface for iterating over collections
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -54,7 +54,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface Iterator
+public interface Iterator<E>
 {
   /**
    * Tests whether there are elements remaining in the collection. In other
@@ -70,7 +70,7 @@
    * @return the next element in the collection
    * @throws NoSuchElementException if there are no more elements
    */
-  Object next();
+  E next();
 
   /**
    * Remove from the underlying collection the last element returned by next
Index: java/util/LinkedHashSet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/LinkedHashSet.java,v
retrieving revision 1.3
diff -u -r1.3 LinkedHashSet.java
--- java/util/LinkedHashSet.java 23 Jan 2002 00:06:10 -0000 1.3
+++ java/util/LinkedHashSet.java 5 Aug 2004 20:49:23 -0000
@@ -1,6 +1,6 @@
 /* LinkedHashSet.java -- a set backed by a LinkedHashMap, for linked
    list traversal.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -88,8 +88,8 @@
  * @since 1.4
  * @status updated to 1.4
  */
-public class LinkedHashSet extends HashSet
-  implements Set, Cloneable, Serializable
+public class LinkedHashSet<T> extends HashSet<T>
+  implements Set<T>, Cloneable, Serializable
 {
   /**
    * Compatible with JDK 1.4.
@@ -140,7 +140,7 @@
    * @param c a collection of initial set elements
    * @throws NullPointerException if c is null
    */
-  public LinkedHashSet(Collection c)
+  public LinkedHashSet(Collection<? extends T> c)
   {
     super(c);
   }
@@ -152,9 +152,8 @@
    * @param load the initial load factor
    * @return the backing HashMap
    */
-  HashMap init(int capacity, float load)
+  HashMap<T, String> init(int capacity, float load)
   {
-    return new LinkedHashMap(capacity, load);
+    return new LinkedHashMap<T, String>(capacity, load);
   }
-
 }
Index: java/util/LinkedList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/LinkedList.java,v
retrieving revision 1.23
diff -u -r1.23 LinkedList.java
--- java/util/LinkedList.java 22 Apr 2004 11:24:39 -0000 1.23
+++ java/util/LinkedList.java 5 Aug 2004 20:49:23 -0000
@@ -71,8 +71,8 @@
  * @since 1.2
  * @status missing javadoc, but complete to 1.4
  */
-public class LinkedList extends AbstractSequentialList
-  implements List, Cloneable, Serializable
+public class LinkedList<T> extends AbstractSequentialList<T>
+  implements List<T>, Cloneable, Serializable
 {
   /**
    * Compatible with JDK 1.2.
@@ -82,12 +82,12 @@
   /**
    * The first element in the list.
    */
-  transient Entry first;
+  transient Entry<T> first;
 
   /**
    * The last element in the list.
    */
-  transient Entry last;
+  transient Entry<T> last;
 
   /**
    * The current length of the list.
@@ -97,22 +97,22 @@
   /**
    * Class to represent an entry in the list. Holds a single element.
    */
-  private static final class Entry
+  private static final class Entry<T>
   {
     /** The element in the list. */
-    Object data;
+    T data;
 
     /** The next list entry, null if this is last. */
-    Entry next;
+    Entry<T> next;
 
     /** The previous list entry, null if this is first. */
-    Entry previous;
+    Entry<T> previous;
 
     /**
      * Construct an entry.
      * @param data the list element
      */
-    Entry(Object data)
+    Entry(T data)
     {
       this.data = data;
     }
@@ -131,9 +131,9 @@
    * @return the entry at position n
    */
   // Package visible for use in nested classes.
-  Entry getEntry(int n)
+  Entry<T> getEntry(int n)
   {
-    Entry e;
+    Entry<T> e;
     if (n < size / 2)
       {
         e = first;
@@ -158,7 +158,7 @@
    * @param e the entry to remove
    */
   // Package visible for use in nested classes.
-  void removeEntry(Entry e)
+  void removeEntry(Entry<T> e)
   {
     modCount++;
     size--;
@@ -224,7 +224,7 @@
    * @param c the collection to populate this list from
    * @throws NullPointerException if c is null
    */
-  public LinkedList(Collection c)
+  public LinkedList(Collection<? extends T> c)
   {
     addAll(c);
   }
@@ -235,7 +235,7 @@
    * @return the first list element
    * @throws NoSuchElementException if the list is empty
    */
-  public Object getFirst()
+  public T getFirst()
   {
     if (size == 0)
       throw new NoSuchElementException();
@@ -248,7 +248,7 @@
    * @return the last list element
    * @throws NoSuchElementException if the list is empty
    */
-  public Object getLast()
+  public T getLast()
   {
     if (size == 0)
       throw new NoSuchElementException();
@@ -261,13 +261,13 @@
    * @return the former first element in the list
    * @throws NoSuchElementException if the list is empty
    */
-  public Object removeFirst()
+  public T removeFirst()
   {
     if (size == 0)
       throw new NoSuchElementException();
     modCount++;
     size--;
-    Object r = first.data;
+    T r = first.data;
 
     if (first.next != null)
       first.next.previous = null;
@@ -285,13 +285,13 @@
    * @return the former last element in the list
    * @throws NoSuchElementException if the list is empty
    */
-  public Object removeLast()
+  public T removeLast()
   {
     if (size == 0)
       throw new NoSuchElementException();
     modCount++;
     size--;
-    Object r = last.data;
+    T r = last.data;
 
     if (last.previous != null)
       last.previous.next = null;
@@ -308,9 +308,9 @@
    *
    * @param o the element to insert
    */
-  public void addFirst(Object o)
+  public void addFirst(T o)
   {
-    Entry e = new Entry(o);
+    Entry<T> e = new Entry(o);
 
     modCount++;
     if (size == 0)
@@ -329,9 +329,9 @@
    *
    * @param o the element to insert
    */
-  public void addLast(Object o)
+  public void addLast(T o)
   {
-    addLastEntry(new Entry(o));
+    addLastEntry(new Entry<T>(o));
   }
 
   /**
@@ -339,7 +339,7 @@
    *
    * @param e the entry to add
    */
-  private void addLastEntry(Entry e)
+  private void addLastEntry(Entry<T> e)
   {
     modCount++;
     if (size == 0)
@@ -362,7 +362,7 @@
    */
   public boolean contains(Object o)
   {
-    Entry e = first;
+    Entry<T> e = first;
     while (e != null)
       {
         if (equals(o, e.data))
@@ -388,9 +388,9 @@
    * @param e the entry to add
    * @return true, as it always succeeds
    */
-  public boolean add(Object o)
+  public boolean add(T o)
   {
-    addLastEntry(new Entry(o));
+    addLastEntry(new Entry<T>(o));
     return true;
   }
 
@@ -403,7 +403,7 @@
    */
   public boolean remove(Object o)
   {
-    Entry e = first;
+    Entry<T> e = first;
     while (e != null)
       {
         if (equals(o, e.data))
@@ -425,7 +425,7 @@
    * @return true if the list was modified
    * @throws NullPointerException if c is null
    */
-  public boolean addAll(Collection c)
+  public boolean addAll(Collection<? extends T> c)
   {
     return addAll(size, c);
   }
@@ -440,7 +440,7 @@
    * @throws NullPointerException if c is null
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
    */
-  public boolean addAll(int index, Collection c)
+  public boolean addAll(int index, Collection<? extends T> c)
   {
     checkBoundsInclusive(index);
     int csize = c.size();
@@ -448,13 +448,13 @@
     if (csize == 0)
       return false;
 
-    Iterator itr = c.iterator();
+    Iterator<? extends T> itr = c.iterator();
 
     // Get the entries just before and after index. If index is at the start
     // of the list, BEFORE is null. If index is at the end of the list, AFTER
     // is null. If the list is empty, both are null.
-    Entry after = null;
-    Entry before = null;
+    Entry<T> after = null;
+    Entry<T> before = null;
     if (index != size)
       {
         after = getEntry(index);
@@ -467,15 +467,15 @@
     // to the first entry, in order to deal with the case where (c == this).
     // [Actually, we don't have to handle this case to fufill the
     // contract for addAll(), but Sun's implementation appears to.]
-    Entry e = new Entry(itr.next());
+    Entry<T> e = new Entry<T>(itr.next());
     e.previous = before;
-    Entry prev = e;
-    Entry firstNew = e;
+    Entry<T> prev = e;
+    Entry<T> firstNew = e;
 
     // Create and link all the remaining entries.
     for (int pos = 1; pos < csize; pos++)
       {
-        e = new Entry(itr.next());
+        e = new Entry<T>(itr.next());
         e.previous = prev;
         prev.next = e;
         prev = e;
@@ -518,7 +518,7 @@
    * @return the element at index
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
    */
-  public Object get(int index)
+  public T get(int index)
   {
     checkBoundsExclusive(index);
     return getEntry(index).data;
@@ -532,11 +532,11 @@
    * @return the prior element
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
    */
-  public Object set(int index, Object o)
+  public T set(int index, T o)
   {
     checkBoundsExclusive(index);
-    Entry e = getEntry(index);
-    Object old = e.data;
+    Entry<T> e = getEntry(index);
+    T old = e.data;
     e.data = o;
     return old;
   }
@@ -548,15 +548,15 @@
    * @param o the element to insert
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
    */
-  public void add(int index, Object o)
+  public void add(int index, T o)
   {
     checkBoundsInclusive(index);
-    Entry e = new Entry(o);
+    Entry<T> e = new Entry<T>(o);
 
     if (index < size)
       {
         modCount++;
-        Entry after = getEntry(index);
+        Entry<T> after = getEntry(index);
         e.next = after;
         e.previous = after.previous;
         if (after.previous == null)
@@ -577,10 +577,10 @@
    * @return the removed element
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
    */
-  public Object remove(int index)
+  public T remove(int index)
   {
     checkBoundsExclusive(index);
-    Entry e = getEntry(index);
+    Entry<T> e = getEntry(index);
     removeEntry(e);
     return e.data;
   }
@@ -594,7 +594,7 @@
   public int indexOf(Object o)
   {
     int index = 0;
-    Entry e = first;
+    Entry<T> e = first;
     while (e != null)
       {
         if (equals(o, e.data))
@@ -614,7 +614,7 @@
   public int lastIndexOf(Object o)
   {
     int index = size - 1;
-    Entry e = last;
+    Entry<T> e = last;
     while (e != null)
       {
         if (equals(o, e.data))
@@ -634,10 +634,10 @@
    *        next(), or size() to be initially positioned at the end of the list
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
    */
-  public ListIterator listIterator(int index)
+  public ListIterator<T> listIterator(int index)
   {
     checkBoundsInclusive(index);
-    return new LinkedListItr(index);
+    return new LinkedListItr<T>(index);
   }
 
   /**
@@ -648,10 +648,10 @@
    */
   public Object clone()
   {
-    LinkedList copy = null;
+    LinkedList<T> copy = null;
     try
       {
-        copy = (LinkedList) super.clone();
+        copy = (LinkedList<T>) super.clone();
       }
     catch (CloneNotSupportedException ex)
       {
@@ -669,7 +669,7 @@
   public Object[] toArray()
   {
     Object[] array = new Object[size];
-    Entry e = first;
+    Entry<T> e = first;
     for (int i = 0; i < size; i++)
       {
         array[i] = e.data;
@@ -692,13 +692,13 @@
    *         an element in this list
    * @throws NullPointerException if a is null
    */
-  public Object[] toArray(Object[] a)
+  <S> public S[] toArray(S[] a)
   {
     if (a.length < size)
-      a = (Object[]) Array.newInstance(a.getClass().getComponentType(), size);
+      a = (S[]) Array.newInstance(a.getClass().getComponentType(), size);
     else if (a.length > size)
       a[size] = null;
-    Entry e = first;
+    Entry<T> e = first;
     for (int i = 0; i < size; i++)
       {
         a[i] = e.data;
@@ -719,7 +719,7 @@
   {
     s.defaultWriteObject();
     s.writeInt(size);
-    Entry e = first;
+    Entry<T> e = first;
     while (e != null)
       {
         s.writeObject(e.data);
@@ -742,7 +742,7 @@
     s.defaultReadObject();
     int i = s.readInt();
     while (--i >= 0)
-      addLastEntry(new Entry(s.readObject()));
+      addLastEntry(new Entry<T>((T) s.readObject()));
   }
 
   /**
@@ -752,19 +752,19 @@
    * @author Original author unknown
    * @author Eric Blake <address@hidden>
    */
-  private final class LinkedListItr implements ListIterator
+  private final class LinkedListItr<T> implements ListIterator<T>
   {
     /** Number of modifications we know about. */
     private int knownMod = modCount;
 
     /** Entry that will be returned by next(). */
-    private Entry next;
+    private Entry<T> next;
 
     /** Entry that will be returned by previous(). */
-    private Entry previous;
+    private Entry<T> previous;
 
     /** Entry that will be affected by remove() or set(). */
-    private Entry lastReturned;
+    private Entry<T> lastReturned;
 
     /** Index of `next'. */
     private int position;
@@ -855,7 +855,7 @@
      * @throws ConcurrentModificationException if the list was modified
      * @throws NoSuchElementException if there is no next
      */
-    public Object next()
+    public T next()
     {
       checkMod();
       if (next == null)
@@ -873,7 +873,7 @@
      * @throws ConcurrentModificationException if the list was modified
      * @throws NoSuchElementException if there is no previous
      */
-    public Object previous()
+    public T previous()
     {
       checkMod();
       if (previous == null)
@@ -915,14 +915,14 @@
      * @param o the element to add
      * @throws ConcurrentModificationException if the list was modified
      */
-    public void add(Object o)
+    public void add(T o)
     {
       checkMod();
       modCount++;
       knownMod++;
       size++;
       position++;
-      Entry e = new Entry(o);
+      Entry<T> e = new Entry<T>(o);
       e.previous = previous;
       e.next = next;
 
@@ -947,7 +947,7 @@
      * @throws ConcurrentModificationException if the list was modified
      * @throws IllegalStateException if there was no last element
      */
-    public void set(Object o)
+    public void set(T o)
     {
       checkMod();
       if (lastReturned == null)
Index: java/util/List.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/List.java,v
retrieving revision 1.10
diff -u -r1.10 List.java
--- java/util/List.java 29 Jul 2004 20:23:18 -0000 1.10
+++ java/util/List.java 5 Aug 2004 20:49:23 -0000
@@ -1,5 +1,5 @@
 /* List.java -- An ordered collection which allows indexed access
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -80,7 +80,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface List extends Collection
+public interface List<E> extends Collection<E>
 {
   /**
    * Insert an element into the list at a given position (optional operation).
@@ -100,7 +100,7 @@
    * @throws NullPointerException if o is null and this list doesn't support
    *         the addition of null values.
    */
-  void add(int index, Object o);
+  void add(int index, E o);
 
   /**
    * Add an element to the end of the list (optional operation). If the list
@@ -118,7 +118,7 @@
    * @throws NullPointerException if o is null and this list doesn't support
    *         the addition of null values.
    */
-  boolean add(Object o);
+  boolean add(E o);
 
   /**
    * Insert the contents of a collection into the list at a given position
@@ -143,7 +143,7 @@
    * @throws NullPointerException if the specified collection is null
    * @see #add(int, Object)
    */
-  boolean addAll(int index, Collection c);
+  boolean addAll(int index, Collection<? extends E> c);
 
   /**
    * Add the contents of a collection to the end of the list (optional
@@ -165,7 +165,7 @@
    *         doesn't support the addition of null values.
    * @see #add(Object)
    */
-  boolean addAll(Collection c);
+  boolean addAll(Collection<? extends E> c);
 
   /**
    * Clear the list, such that a subsequent call to isEmpty() would return
@@ -202,7 +202,7 @@
    *         list does not support null values.
    * @see #contains(Object)
    */
-  boolean containsAll(Collection c);
+  boolean containsAll(Collection<?> c);
 
   /**
    * Test whether this list is equal to another object. A List is defined to be
@@ -226,7 +226,7 @@
    * @return the element at index index in this list
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
    */
-  Object get(int index);
+  E get(int index);
 
   /**
    * Obtains a hash code for this list. In order to obey the general
@@ -276,7 +276,7 @@
    *
    * @return an Iterator over the elements of this list, in order
    */
-  Iterator iterator();
+  Iterator<E> iterator();
 
   /**
    * Obtain the last index at which a given object is to be found in this
@@ -297,7 +297,7 @@
    * @return a ListIterator over the elements of this list, in order, starting
    *         at the beginning
    */
-  ListIterator listIterator();
+  ListIterator<E> listIterator();
 
   /**
    * Obtain a ListIterator over this list, starting at a given position.
@@ -310,7 +310,7 @@
    *         at index
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
    */
-  ListIterator listIterator(int index);
+  ListIterator<E> listIterator(int index);
 
   /**
    * Remove the element at a given position in this list (optional operation).
@@ -322,7 +322,7 @@
    *         remove operation
    * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt;= size()
    */
-  Object remove(int index);
+  E remove(int index);
 
   /**
    * Remove the first occurence of an object from this list (optional
@@ -357,7 +357,7 @@
    * @see #remove(Object)
    * @see #contains(Object)
    */
-  boolean removeAll(Collection c);
+  boolean removeAll(Collection<?> c);
 
   /**
    * Remove all elements of this list that are not contained in a given
@@ -376,7 +376,7 @@
    * @see #remove(Object)
    * @see #contains(Object)
    */
-  boolean retainAll(Collection c);
+  boolean retainAll(Collection<?> c);
 
   /**
    * Replace an element of this list with another object (optional operation).
@@ -394,7 +394,7 @@
    * @throws NullPointerException if o is null and this
    *         list does not support null values.
    */
-  Object set(int index, Object o);
+  E set(int index, E o);
 
   /**
    * Get the number of elements in this list. If the list contains more
@@ -420,7 +420,7 @@
    * @throws IndexOutOfBoundsException if fromIndex &lt; 0
    *         || toIndex &gt; size() || fromIndex &gt; toIndex
    */
-  List subList(int fromIndex, int toIndex);
+  List<E> subList(int fromIndex, int toIndex);
 
   /**
    * Copy the current contents of this list into an array.
@@ -447,5 +447,5 @@
    *         collection is not a subtype of the element type of a
    * @throws NullPointerException if the specified array is null
    */
-  Object[] toArray(Object[] a);
+  <T> T[] toArray(T[] a);
 }
Index: java/util/ListIterator.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/ListIterator.java,v
retrieving revision 1.7
diff -u -r1.7 ListIterator.java
--- java/util/ListIterator.java 22 Jan 2002 22:27:01 -0000 1.7
+++ java/util/ListIterator.java 5 Aug 2004 20:49:23 -0000
@@ -1,5 +1,5 @@
 /* ListIterator.java -- Extended Iterator for iterating over ordered lists
-   Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -59,7 +59,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface ListIterator extends Iterator
+public interface ListIterator<E> extends Iterator<E>
 {
   /**
    * Tests whether there are elements remaining in the list in the forward
@@ -88,7 +88,7 @@
    * @return the next element in the list in the forward direction
    * @throws NoSuchElementException if there are no more elements
    */
-  Object next();
+  E next();
 
   /**
    * Obtain the next element in the list in the reverse direction. Repeated
@@ -100,7 +100,7 @@
    * @return the next element in the list in the reverse direction
    * @throws NoSuchElementException if there are no more elements
    */
-  Object previous();
+  E previous();
 
   /**
    * Find the index of the element that would be returned by a call to next.
@@ -134,7 +134,7 @@
    * @throws UnsupportedOperationException if this ListIterator does not
    *         support the add operation
    */
-  void add(Object o);
+  void add(E o);
 
   /**
    * Remove from the list the element last returned by a call to next or
@@ -166,5 +166,5 @@
    * @throws UnsupportedOperationException if this ListIterator does not
    *         support the set operation
    */
-  void set(Object o);
+  void set(E o);
 }
Index: java/util/Map.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Map.java,v
retrieving revision 1.13
diff -u -r1.13 Map.java
--- java/util/Map.java 29 Jul 2004 20:23:18 -0000 1.13
+++ java/util/Map.java 5 Aug 2004 20:49:23 -0000
@@ -78,7 +78,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface Map
+public interface Map<K, V>
 {
   /**
    * Remove all entries from this Map (optional operation).
@@ -127,7 +127,7 @@
    * @return the set view of all mapping entries
    * @see Map.Entry
    */
-  Set entrySet();
+  Set<Map.Entry<K, V>> entrySet();
 
   /**
    * Compares the specified object with this map for equality. Returns
@@ -153,7 +153,7 @@
    * @throws NullPointerException if this map does not accept null keys
    * @see #containsKey(Object)
    */
-  Object get(Object key);
+  V get(Object key);
 
   /**
    * Associates the given key to the given value (optional operation). If the
@@ -172,7 +172,7 @@
    *         and the map forbids null keys or values
    * @see #containsKey(Object)
    */
-  Object put(Object key, Object value);
+  V put(K key, V value);
 
   /**
    * Returns the hash code for this map. This is the sum of all hashcodes
@@ -204,7 +204,7 @@
    *
    * @return the set view of all keys
    */
-  Set keySet();
+  Set<K> keySet();
 
   /**
    * Copies all entries of the given map to this one (optional operation). If
@@ -219,7 +219,7 @@
    *         if <code>m</code> is null.
    * @see #put(Object, Object)
    */
-  void putAll(Map m);
+  void putAll(Map<? extends K, ? extends V> m);
 
   /**
    * Removes the mapping for this key if present (optional operation). If
@@ -234,7 +234,7 @@
    * @throws ClassCastException if the type of the key is not a valid type
    *         for this map.
    */
-  Object remove(Object key);
+  V remove(Object o);
 
   /**
    * Returns the number of key-value mappings in the map. If there are more
@@ -257,7 +257,7 @@
    *
    * @return the collection view of all values
    */
-  Collection values();
+  Collection<V> values();
 
   /**
    * A map entry (key-value pair). The Map.entrySet() method returns a set
@@ -273,14 +273,14 @@
    * @since 1.2
    * @status updated to 1.4
    */
-  interface Entry
+  interface Entry<K, V>
   {
     /**
      * Get the key corresponding to this entry.
      *
      * @return the key
      */
-    Object getKey();
+    K getKey();
 
     /**
      * Get the value corresponding to this entry. If you already called
@@ -288,7 +288,7 @@
      *
      * @return the value
      */
-    Object getValue();
+    V getValue();
 
     /**
      * Replaces the value with the specified object (optional operation).
@@ -303,7 +303,7 @@
      *         prevents it from existing in this map
      * @throws NullPointerException if the map forbids null values
      */
-    Object setValue(Object value);
+    V setValue(V value);
 
 
     /**
Index: java/util/Set.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Set.java,v
retrieving revision 1.8
diff -u -r1.8 Set.java
--- java/util/Set.java 29 Jul 2004 20:23:18 -0000 1.8
+++ java/util/Set.java 5 Aug 2004 20:49:23 -0000
@@ -1,5 +1,5 @@
 /* Set.java -- A collection that prohibits duplicates
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -66,7 +66,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface Set extends Collection
+public interface Set<E> extends Collection<E>
 {
   /**
    * Adds the specified element to the set if it is not already present
@@ -83,7 +83,7 @@
    *         being added
    * @throws NullPointerException if null is not permitted in this set
    */
-  boolean add(Object o);
+  boolean add(E o);
 
   /**
    * Adds all of the elements of the given collection to this set (optional
@@ -102,7 +102,7 @@
    *         if the argument c is null
    * @see #add(Object)
    */
-  boolean addAll(Collection c);
+  boolean addAll(Collection<? extends E> c);
 
   /**
    * Removes all elements from this set (optional operation). This set will
@@ -139,7 +139,7 @@
    *         set doesn't support null values.
    * @see #contains(Object)
    */
-  boolean containsAll(Collection c);
+  boolean containsAll(Collection<?> c);
 
   /**
    * Compares the specified object to this for equality. For sets, the object
@@ -173,7 +173,7 @@
    *
    * @return a set iterator
    */
-  Iterator iterator();
+  Iterator<E> iterator();
 
   /**
    * Removes the specified element from this set (optional operation). If
@@ -205,7 +205,7 @@
    *         set doesn't support removing null values.
    * @see #remove(Object)
    */
-  boolean removeAll(Collection c);
+  boolean removeAll(Collection<?> c);
 
   /**
    * Retains only the elements in this set that are also in the specified
@@ -222,7 +222,7 @@
    *         set doesn't support retaining null values.
    * @see #remove(Object)
    */
-  boolean retainAll(Collection c);
+  boolean retainAll(Collection<?> c);
 
   /**
    * Returns the number of elements in the set. If there are more
@@ -260,5 +260,5 @@
    * @throws NullPointerException if a is null
    * @see #toArray()
    */
-  Object[] toArray(Object[] a);
+  <T> T[] toArray(T[] a);
 }
Index: java/util/SortedMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/SortedMap.java,v
retrieving revision 1.7
diff -u -r1.7 SortedMap.java
--- java/util/SortedMap.java 29 Jul 2004 20:23:18 -0000 1.7
+++ java/util/SortedMap.java 5 Aug 2004 20:49:23 -0000
@@ -1,5 +1,5 @@
 /* SortedMap.java -- A map that makes guarantees about the order of its keys
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -72,7 +72,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface SortedMap extends Map
+public interface SortedMap<K, V> extends Map<K, V>
 {
   /**
    * Returns the comparator used in sorting this map, or null if it is
@@ -80,7 +80,7 @@
    *
    * @return the sorting comparator
    */
-  Comparator comparator();
+  Comparator<? super K> comparator();
 
   /**
    * Returns the first (lowest sorted) key in the map.
@@ -88,7 +88,7 @@
    * @return the first key
    * @throws NoSuchElementException if this map is empty.
    */
-  Object firstKey();
+  K firstKey();
 
   /**
    * Returns a view of the portion of the map strictly less than toKey. The
@@ -110,7 +110,7 @@
    * @throws NullPointerException if toKey is null but the map does not allow
    *         null keys
    */
-  SortedMap headMap(Object toKey);
+  SortedMap<K, V> headMap(K toKey);
 
   /**
    * Returns the last (highest sorted) key in the map.
@@ -118,7 +118,7 @@
    * @return the last key
    * @throws NoSuchElementException if this map is empty.
    */
-  Object lastKey();
+  K lastKey();
 
   /**
    * Returns a view of the portion of the map greater than or equal to
@@ -145,7 +145,7 @@
    * @throws NullPointerException if fromKey or toKey is null but the map
    *         does not allow null keys
    */
-  SortedMap subMap(Object fromKey, Object toKey);
+  SortedMap<K, V> subMap(K fromKey, K toKey);
 
   /**
    * Returns a view of the portion of the map greater than or equal to
@@ -168,5 +168,5 @@
    * @throws NullPointerException if fromKey is null but the map does not allow
    *         null keys
    */
-  SortedMap tailMap(Object fromKey);
+  SortedMap<K, V> tailMap(K fromKey);
 }
Index: java/util/SortedSet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/SortedSet.java,v
retrieving revision 1.7
diff -u -r1.7 SortedSet.java
--- java/util/SortedSet.java 29 Jul 2004 20:23:18 -0000 1.7
+++ java/util/SortedSet.java 5 Aug 2004 20:49:23 -0000
@@ -1,6 +1,6 @@
 /* SortedSet.java -- A set that makes guarantees about the order of its
    elements
-   Copyright (C) 1998, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -74,7 +74,7 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public interface SortedSet extends Set
+public interface SortedSet<E> extends Set<E>
 {
   /**
    * Returns the comparator used in sorting this set, or null if it is
@@ -82,7 +82,7 @@
    *
    * @return the sorting comparator
    */
-  Comparator comparator();
+  Comparator<? super E> comparator();
 
   /**
    * Returns the first (lowest sorted) element in the map.
@@ -90,7 +90,7 @@
    * @return the first element
    * @throws NoSuchElementException if the set is empty.
    */
-  Object first();
+  E first();
 
   /**
    * Returns a view of the portion of the set strictly less than toElement. The
@@ -113,7 +113,7 @@
    * @throws NullPointerException if toElement is null but the map does not
    *         allow null elements
    */
-  SortedSet headSet(Object toElement);
+  SortedSet<E> headSet(E toElement);
 
   /**
    * Returns the last (highest sorted) element in the map.
@@ -121,7 +121,7 @@
    * @return the last element
    * @throws NoSuchElementException if the set is empty.
    */
-  Object last();
+  E last();
 
   /**
    * Returns a view of the portion of the set greater than or equal to
@@ -148,7 +148,7 @@
    * @throws NullPointerException if fromElement or toElement is null but the
    *         set does not allow null elements
    */
-  SortedSet subSet(Object fromElement, Object toElement);
+  SortedSet<E> subSet(E fromElement, E toElement);
 
   /**
    * Returns a view of the portion of the set greater than or equal to
@@ -171,5 +171,5 @@
    * @throws NullPointerException if fromElement is null but the set does not
    *         allow null elements
    */
-  SortedSet tailSet(Object fromElement);
+  SortedSet<E> tailSet(E fromElement);
 }
Index: java/util/Stack.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Stack.java,v
retrieving revision 1.9
diff -u -r1.9 Stack.java
--- java/util/Stack.java 22 Jan 2002 22:27:01 -0000 1.9
+++ java/util/Stack.java 5 Aug 2004 20:49:23 -0000
@@ -1,6 +1,6 @@
 /* Stack.java - Class that provides a Last In First Out (LIFO)
    datatype, known more commonly as a Stack
-   Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2001, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -58,7 +58,7 @@
  * @since 1.0
  * @status updated to 1.4
  */
-public class Stack extends Vector
+public class Stack<T> extends Vector<T>
 {
   // We could use Vector methods internally for the following methods,
   // but have used Vector fields directly for efficiency (i.e. this
@@ -84,7 +84,7 @@
    * @return the Object pushed onto the stack
    * @see Vector#addElement(Object)
    */
-  public Object push(Object item)
+  public T push(T item)
   {
     // When growing the Stack, use the Vector routines in case more
     // memory is needed.
@@ -101,13 +101,13 @@
    * @return the Object popped from the stack
    * @throws EmptyStackException if the stack is empty
    */
-  public synchronized Object pop()
+  public synchronized T pop()
   {
     if (elementCount == 0)
       throw new EmptyStackException();
 
     modCount++;
-    Object obj = elementData[--elementCount];
+    T obj = elementData[--elementCount];
 
     // Set topmost element to null to assist the gc in cleanup.
     elementData[elementCount] = null;
@@ -120,7 +120,7 @@
    * @return the top Object on the stack
    * @throws EmptyStackException if the stack is empty
    */
-  public synchronized Object peek()
+  public synchronized T peek()
   {
     if (elementCount == 0)
       throw new EmptyStackException();
Index: java/util/TreeSet.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/TreeSet.java,v
retrieving revision 1.15
diff -u -r1.15 TreeSet.java
--- java/util/TreeSet.java 22 Apr 2004 11:24:39 -0000 1.15
+++ java/util/TreeSet.java 5 Aug 2004 20:49:24 -0000
@@ -79,8 +79,8 @@
  * @since 1.2
  * @status updated to 1.4
  */
-public class TreeSet extends AbstractSet
-  implements SortedSet, Cloneable, Serializable
+public class TreeSet<T> extends AbstractSet<T>
+  implements SortedSet<T>, Cloneable, Serializable
 {
   /**
    * Compatible with JDK 1.2.
@@ -92,7 +92,7 @@
    */
   // Not final because of readObject. This will always be one of TreeMap or
   // TreeMap.SubMap, which both extend AbstractMap.
-  private transient SortedMap map;
+  private transient SortedMap<T, String> map;
 
   /**
    * Construct a new TreeSet whose backing TreeMap using the "natural"
@@ -103,7 +103,7 @@
    */
   public TreeSet()
   {
-    map = new TreeMap();
+    map = new TreeMap<T, String>();
   }
 
   /**
@@ -113,9 +113,9 @@
    *
    * @param comparator the Comparator this Set will use
    */
-  public TreeSet(Comparator comparator)
+  public TreeSet(Comparator<? super T> comparator)
   {
-    map = new TreeMap(comparator);
+    map = new TreeMap<T, String>(comparator);
   }
 
   /**
@@ -130,9 +130,9 @@
    * @throws NullPointerException if the collection is null
    * @see Comparable
    */
-  public TreeSet(Collection collection)
+  public TreeSet(Collection<? extends T> collection)
   {
-    map = new TreeMap();
+    map = new TreeMap<T, String>();
     addAll(collection);
   }
 
@@ -145,11 +145,11 @@
    *        and will initialize itself with all its elements
    * @throws NullPointerException if sortedSet is null
    */
-  public TreeSet(SortedSet sortedSet)
+  public TreeSet(SortedSet<? extends T> sortedSet)
   {
-    map = new TreeMap(sortedSet.comparator());
-    Iterator itr = sortedSet.iterator();
-    ((TreeMap) map).putKeysLinear(itr, sortedSet.size());
+    map = new TreeMap<T, String>(sortedSet.comparator());
+    Iterator<? extends T> itr = sortedSet.iterator();
+    ((TreeMap<T>) map).putKeysLinear(itr, sortedSet.size());
   }
 
   /**
@@ -158,7 +158,7 @@
    *
    * @param backingMap the submap
    */
-  private TreeSet(SortedMap backingMap)
+  private TreeSet(SortedMap<T> backingMap)
   {
     map = backingMap;
   }
@@ -171,7 +171,7 @@
    * @throws ClassCastException if the element cannot be compared with objects
    *         already in the set
    */
-  public boolean add(Object obj)
+  public boolean add(T obj)
   {
     return map.put(obj, "") == null;
   }
@@ -185,11 +185,11 @@
    * @throws ClassCastException if an element in c cannot be compared with
    *         objects already in the set
    */
-  public boolean addAll(Collection c)
+  public boolean addAll(Collection<? extends T> c)
   {
     boolean result = false;
     int pos = c.size();
-    Iterator itr = c.iterator();
+    Iterator<? extends T> itr = c.iterator();
     while (--pos >= 0)
       result |= (map.put(itr.next(), "") == null);
     return result;
@@ -210,12 +210,12 @@
    */
   public Object clone()
   {
-    TreeSet copy = null;
+    TreeSet<T> copy = null;
     try
       {
-        copy = (TreeSet) super.clone();
+        copy = (TreeSet,T>) super.clone();
         // Map may be either TreeMap or TreeMap.SubMap, hence the ugly casts.
-        copy.map = (SortedMap) ((AbstractMap) map).clone();
+        copy.map = (SortedMap<T>) ((AbstractMap<T>) map).clone();
       }
     catch (CloneNotSupportedException x)
       {
@@ -229,7 +229,7 @@
    *
    * @return the comparator, or null if the set uses natural ordering
    */
-  public Comparator comparator()
+  public Comparator<? super T> comparator()
   {
     return map.comparator();
   }
@@ -253,7 +253,7 @@
    * @return the first element
    * @throws NoSuchElementException if the set is empty
    */
-  public Object first()
+  public T first()
   {
     return map.firstKey();
   }
@@ -273,9 +273,9 @@
    * @throws NullPointerException if to is null, but the comparator does not
    *         tolerate null elements
    */
-  public SortedSet headSet(Object to)
+  public SortedSet headSet(T to)
   {
-    return new TreeSet(map.headMap(to));
+    return new TreeSet<T>(map.headMap(to));
   }
 
   /**
@@ -294,7 +294,7 @@
    *
    * @return an iterator
    */
-  public Iterator iterator()
+  public Iterator<T> iterator()
   {
     return map.keySet().iterator();
   }
@@ -305,7 +305,7 @@
    * @return the last element
    * @throws NoSuchElementException if the set is empty
    */
-  public Object last()
+  public T last()
   {
     return map.lastKey();
   }
@@ -351,9 +351,9 @@
    *         does not tolerate null elements
    * @throws IllegalArgumentException if from is greater than to
    */
-  public SortedSet subSet(Object from, Object to)
+  public SortedSet<T> subSet(T from, T to)
   {
-    return new TreeSet(map.subMap(from, to));
+    return new TreeSet<T>(map.subMap(from, to));
   }
 
   /**
@@ -371,9 +371,9 @@
    * @throws NullPointerException if from is null, but the comparator
    *         does not tolerate null elements
    */
-  public SortedSet tailSet(Object from)
+  public SortedSet<T> tailSet(T from)
   {
-    return new TreeSet(map.tailMap(from));
+    return new TreeSet<T>(map.tailMap(from));
   }
 
   /**
@@ -387,7 +387,7 @@
   private void writeObject(ObjectOutputStream s) throws IOException
   {
     s.defaultWriteObject();
-    Iterator itr = map.keySet().iterator();
+    Iterator<T> itr = map.keySet().iterator();
     int pos = map.size();
     s.writeObject(map.comparator());
     s.writeInt(pos);
@@ -408,9 +408,9 @@
     throws IOException, ClassNotFoundException
   {
     s.defaultReadObject();
-    Comparator comparator = (Comparator) s.readObject();
+    Comparator<? super T> comparator = (Comparator<? super T>) s.readObject();
     int size = s.readInt();
-    map = new TreeMap(comparator);
-    ((TreeMap) map).putFromObjStream(s, size, false);
+    map = new TreeMap<T>(comparator);
+    ((TreeMap<T>) map).putFromObjStream(s, size, false);
   }
 }
Index: java/util/Vector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Vector.java,v
retrieving revision 1.20
diff -u -r1.20 Vector.java
--- java/util/Vector.java 22 Apr 2004 11:24:39 -0000 1.20
+++ java/util/Vector.java 5 Aug 2004 20:49:24 -0000
@@ -78,8 +78,8 @@
  * @since 1.0
  * @status updated to 1.4
  */
-public class Vector extends AbstractList
-  implements List, RandomAccess, Cloneable, Serializable
+public class Vector<T> extends AbstractList<T>
+  implements List<T>, RandomAccess, Cloneable, Serializable
 {
   /**
    * Compatible with JDK 1.0+.
@@ -91,7 +91,7 @@
    * in positions 0 through elementCount - 1, and all remaining slots are null.
    * @serial the elements
    */
-  protected Object[] elementData;
+  protected T[] elementData;
 
   /**
    * The number of elements currently in the vector, also returned by
@@ -126,10 +126,10 @@
    * @throws NullPointerException if c is null
    * @since 1.2
    */
-  public Vector(Collection c)
+  public Vector(Collection<? extends T> c)
   {
     elementCount = c.size();
-    elementData = c.toArray(new Object[elementCount]);
+    elementData = c.toArray(new T[elementCount]);
   }
 
   /**
@@ -145,7 +145,7 @@
   {
     if (initialCapacity < 0)
       throw new IllegalArgumentException();
-    elementData = new Object[initialCapacity];
+    elementData = new T[initialCapacity];
     this.capacityIncrement = capacityIncrement;
   }
 
@@ -188,7 +188,7 @@
     // vector since that is a much less likely case; it's more efficient to
     // not do the check and lose a bit of performance in that infrequent case
 
-    Object[] newArray = new Object[elementCount];
+    T[] newArray = new T[elementCount];
     System.arraycopy(elementData, 0, newArray, 0, elementCount);
     elementData = newArray;
   }
@@ -214,7 +214,7 @@
     else
       newCapacity = elementData.length + capacityIncrement;
 
-    Object[] newArray = new Object[Math.max(newCapacity, minCapacity)];
+    T[] newArray = new T[Math.max(newCapacity, minCapacity)];
 
     System.arraycopy(elementData, 0, newArray, 0, elementCount);
     elementData = newArray;
@@ -280,9 +280,9 @@
    * @see #iterator()
    */
   // No need to synchronize as the Enumeration is not thread-safe!
-  public Enumeration elements()
+  public Enumeration<T> elements()
   {
-    return new Enumeration()
+    return new Enumeration<T>()
     {
       private int i = 0;
 
@@ -291,7 +291,7 @@
         return i < elementCount;
       }
 
-      public Object nextElement()
+      public T nextElement()
       {
         if (i >= elementCount)
           throw new NoSuchElementException();
@@ -381,7 +381,7 @@
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt;= size()
    * @see #get(int)
    */
-  public synchronized Object elementAt(int index)
+  public synchronized T elementAt(int index)
   {
     checkBoundExclusive(index);
     return elementData[index];
@@ -393,7 +393,7 @@
    * @return the first Object in the Vector
    * @throws NoSuchElementException the Vector is empty
    */
-  public synchronized Object firstElement()
+  public synchronized T firstElement()
   {
     if (elementCount == 0)
       throw new NoSuchElementException();
@@ -407,7 +407,7 @@
    * @return the last Object in the Vector
    * @throws NoSuchElementException the Vector is empty
    */
-  public synchronized Object lastElement()
+  public synchronized T lastElement()
   {
     if (elementCount == 0)
       throw new NoSuchElementException();
@@ -423,7 +423,7 @@
    * @throws ArrayIndexOutOfBoundsException the index is out of range
    * @see #set(int, Object)
    */
-  public void setElementAt(Object obj, int index)
+  public void setElementAt(T obj, int index)
   {
     set(index, obj);
   }
@@ -450,7 +450,7 @@
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt; size()
    * @see #add(int, Object)
    */
-  public synchronized void insertElementAt(Object obj, int index)
+  public synchronized void insertElementAt(T obj, int index)
   {
     checkBoundInclusive(index);
     if (elementCount == elementData.length)
@@ -468,7 +468,7 @@
    *
    * @param obj the object to add to the Vector
    */
-  public synchronized void addElement(Object obj)
+  public synchronized void addElement(T obj)
   {
     if (elementCount == elementData.length)
       ensureCapacity(elementCount + 1);
@@ -566,11 +566,11 @@
    * @throws NullPointerException if <code>a</code> is null
    * @since 1.2
    */
-  public synchronized Object[] toArray(Object[] a)
+  <S> public synchronized S[] toArray(S[] a)
   {
     if (a.length < elementCount)
-      a = (Object[]) Array.newInstance(a.getClass().getComponentType(),
-                                       elementCount);
+      a = (S[]) Array.newInstance(a.getClass().getComponentType(),
+                                 elementCount);
     else if (a.length > elementCount)
       a[elementCount] = null;
     System.arraycopy(elementData, 0, a, 0, elementCount);
@@ -585,7 +585,7 @@
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt;= size()
    * @since 1.2
    */
-  public Object get(int index)
+  public T get(int index)
   {
     return elementAt(index);
   }
@@ -600,10 +600,10 @@
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt;= size()
    * @since 1.2
    */
-  public synchronized Object set(int index, Object element)
+  public synchronized T set(int index, T element)
   {
     checkBoundExclusive(index);
-    Object temp = elementData[index];
+    T temp = elementData[index];
     elementData[index] = element;
     return temp;
   }
@@ -615,7 +615,7 @@
    * @return true, as specified by List
    * @since 1.2
    */
-  public boolean add(Object o)
+  public boolean add(T o)
   {
     addElement(o);
     return true;
@@ -643,7 +643,7 @@
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt; size()
    * @since 1.2
    */
-  public void add(int index, Object element)
+  public void add(int index, T element)
   {
     insertElementAt(element, index);
   }
@@ -656,10 +656,10 @@
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt;= size()
    * @since 1.2
    */
-  public synchronized Object remove(int index)
+  public synchronized T remove(int index)
   {
     checkBoundExclusive(index);
-    Object temp = elementData[index];
+    T temp = elementData[index];
     modCount++;
     elementCount--;
     if (index < elementCount)
@@ -685,7 +685,7 @@
    * @throws NullPointerException if c is null
    * @since 1.2
    */
-  public synchronized boolean containsAll(Collection c)
+  public synchronized boolean containsAll(Collection<?> c)
   {
     // Here just for the sychronization.
     return super.containsAll(c);
@@ -701,7 +701,7 @@
    * @throws NullPointerException if c is null
    * @since 1.2
    */
-  public synchronized boolean addAll(Collection c)
+  public synchronized boolean addAll(Collection<? extends T> c)
   {
     return addAll(elementCount, c);
   }
@@ -714,7 +714,7 @@
    * @throws NullPointerException if c is null
    * @since 1.2
    */
-  public synchronized boolean removeAll(Collection c)
+  public synchronized boolean removeAll(Collection<?> c)
   {
     if (c == null)
       throw new NullPointerException();
@@ -743,7 +743,7 @@
    * @throws NullPointerException if c is null
    * @since 1.2
    */
-  public synchronized boolean retainAll(Collection c)
+  public synchronized boolean retainAll(Collection<?> c)
   {
     if (c == null)
       throw new NullPointerException();
@@ -775,7 +775,7 @@
    * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt; size()
    * @since 1.2
    */
-  public synchronized boolean addAll(int index, Collection c)
+  public synchronized boolean addAll(int index, Collection<? extends T> c)
   {
     checkBoundInclusive(index);
     Iterator itr = c.iterator();
@@ -849,12 +849,12 @@
    * @see ConcurrentModificationException
    * @since 1.2
    */
-  public synchronized List subList(int fromIndex, int toIndex)
+  public synchronized List<T> subList(int fromIndex, int toIndex)
   {
-    List sub = super.subList(fromIndex, toIndex);
+    List<T> sub = super.subList(fromIndex, toIndex);
     // We must specify the correct object to synchronize upon, hence the
     // use of a non-public API
-    return new Collections.SynchronizedList(this, sub);
+    return new Collections.SynchronizedList<T>(this, sub);
   }
 
   /**




reply via email to

[Prev in Thread] Current Thread [Next in Thread]