[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] [generics] Patch: FYI: minor fixes all over
From: |
Tom Tromey |
Subject: |
[cp-patches] [generics] Patch: FYI: minor fixes all over |
Date: |
01 Nov 2004 08:51:13 -0700 |
I'm checking this in on the generics branch.
I did some hacking on gcjx this weekend, and it is at the point where
it found a bunch of errors on the generics branch. Here's a patch to
fix them.
Tom
Index: ChangeLog
from Tom Tromey <address@hidden>
* java/util/AbstractMap.java: Removed old FIXME comment.
* java/lang/Long.java (rotateRight): Fixed return type.
* java/lang/Integer.java (reverse): Use correct name for
variable.
* java/lang/Character.java (valueOf): Use MIN_VALUE, not
MIN_CACHE.
* java/lang/Byte.java (valueOf): Use MIN_VALUE, not MIN_CACHE.
* gnu/java/util/DoubleEnumeration.java: Genericized.
* java/lang/Appendable.java (append): Throws IOException.
* java/util/Hashtable.java: Genericized.
* java/util/HashMap.java (putAll): Use correct type for iterator.
(putAllInternal): Likewise.
* java/lang/Class.java (cast): Call VMClass.cast.
* java/util/Collections.java (UnmodifiableMap.remove): Corrected
return type.
(entrySet): Likewise.
(entries): Corrected type.
* vm/reference/java/lang/reflect/Constructor.java
(getTypeParameters): Stubbed.
Index: gnu/java/util/DoubleEnumeration.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/util/DoubleEnumeration.java,v
retrieving revision 1.3
diff -u -r1.3 DoubleEnumeration.java
--- gnu/java/util/DoubleEnumeration.java 23 Apr 2004 21:13:20 -0000 1.3
+++ gnu/java/util/DoubleEnumeration.java 1 Nov 2004 15:52:20 -0000
@@ -1,5 +1,5 @@
/* gnu.java.util.DoubleEnumeration
- 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.
@@ -63,7 +63,7 @@
* @author Jochen Hoenicke
* @author Mark Wielaard (address@hidden)
*/
-public class DoubleEnumeration implements Enumeration
+public class DoubleEnumeration<T> implements Enumeration<T>
{
/**
* This is true as long as one of the enumerations has more
@@ -82,17 +82,17 @@
/**
* The first enumeration.
*/
- private Enumeration e1;
+ private Enumeration<T> e1;
/**
* The second enumeration.
*/
- private Enumeration e2;
+ private Enumeration<T> e2;
/**
* Creates a new Enumeration combining the given two enumerations.
* The enumerations mustn't be accessed by other classes.
*/
- public DoubleEnumeration(Enumeration e1, Enumeration e2)
+ public DoubleEnumeration(Enumeration<T> e1, Enumeration<T> e2)
{
this.e1 = e1;
this.e2 = e2;
@@ -126,7 +126,7 @@
* element of the second enumeration. If both enumeration don't have
* any elements it throws a <code>NoSuchElementException</code>.
*/
- public Object nextElement()
+ public T nextElement()
{
if (!hasMoreElements())
throw new NoSuchElementException();
Index: java/lang/Appendable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Attic/Appendable.java,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 Appendable.java
--- java/lang/Appendable.java 26 Sep 2004 23:02:09 -0000 1.1.2.2
+++ java/lang/Appendable.java 1 Nov 2004 15:52:20 -0000
@@ -37,6 +37,8 @@
package java.lang;
+import java.io.IOException;
+
/**
* <p>
* An <code>Appendable</code> object is one to which a sequence of Unicode
@@ -71,7 +73,7 @@
* @return a reference to this object.
* @throws IOException if an I/O error occurs.
*/
- Appendable append(char c);
+ Appendable append(char c) throws IOException;
/**
* Appends the specified sequence of Unicode characters to this
@@ -86,7 +88,7 @@
* @return a reference to this object.
* @throws IOException if an I/O error occurs.
*/
- Appendable append(CharSequence seq);
+ Appendable append(CharSequence seq) throws IOException;
/**
* Appends the specified subsequence of Unicode characters to this
@@ -111,6 +113,5 @@
* the start index occurs after the end index, or the end index is
* beyond the end of the sequence.
*/
- Appendable append(CharSequence seq, int start, int end);
-
+ Appendable append(CharSequence seq, int start, int end) throws IOException;
}
Index: java/lang/Byte.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Byte.java,v
retrieving revision 1.22.2.2
diff -u -r1.22.2.2 Byte.java
--- java/lang/Byte.java 9 Oct 2004 23:12:26 -0000 1.22.2.2
+++ java/lang/Byte.java 1 Nov 2004 15:52:20 -0000
@@ -214,9 +214,9 @@
{
synchronized (byteCache)
{
- if (byteCache[val - MIN_CACHE] == null)
- byteCache[val - MIN_CACHE] = new Byte(val);
- return byteCache[val - MIN_CACHE];
+ if (byteCache[val - MIN_VALUE] == null)
+ byteCache[val - MIN_VALUE] = new Byte(val);
+ return byteCache[val - MIN_VALUE];
}
}
Index: java/lang/Character.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Character.java,v
retrieving revision 1.33.2.2
diff -u -r1.33.2.2 Character.java
--- java/lang/Character.java 9 Oct 2004 23:12:26 -0000 1.33.2.2
+++ java/lang/Character.java 1 Nov 2004 15:52:21 -0000
@@ -2276,9 +2276,9 @@
return new Character(val);
synchronized (charCache)
{
- if (charCache[val - MIN_CACHE] == null)
- charCache[val - MIN_CACHE] = new Character(val);
- return charCache[val - MIN_CACHE];
+ if (charCache[val - MIN_VALUE] == null)
+ charCache[val - MIN_VALUE] = new Character(val);
+ return charCache[val - MIN_VALUE];
}
}
Index: java/lang/Class.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Class.java,v
retrieving revision 1.22.2.3
diff -u -r1.22.2.3 Class.java
--- java/lang/Class.java 8 Aug 2004 06:38:26 -0000 1.22.2.3
+++ java/lang/Class.java 1 Nov 2004 15:52:21 -0000
@@ -1263,7 +1263,7 @@
*/
public K cast(Object obj)
{
- return VMClassLoader.cast(obj, this);
+ return VMClass.cast(obj, this);
}
/**
Index: java/lang/Integer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Integer.java,v
retrieving revision 1.29.2.2
diff -u -r1.29.2.2 Integer.java
--- java/lang/Integer.java 9 Oct 2004 23:12:26 -0000 1.29.2.2
+++ java/lang/Integer.java 1 Nov 2004 15:52:21 -0000
@@ -663,11 +663,11 @@
public static int reverse(int val)
{
// Successively swap alternating bit groups.
- x = ((x >> 1) & 0x55555555) + ((x << 1) & ~0x55555555);
- x = ((x >> 2) & 0x33333333) + ((x << 2) & ~0x33333333);
- x = ((x >> 4) & 0x0f0f0f0f) + ((x << 4) & ~0x0f0f0f0f);
- x = ((x >> 8) & 0x00ff00ff) + ((x << 8) & ~0x00ff00ff);
- return ((x >> 16) & 0x0000ffff) + ((x << 16) & ~0x0000ffff);
+ val = ((val >> 1) & 0x55555555) + ((val << 1) & ~0x55555555);
+ val = ((val >> 2) & 0x33333333) + ((val << 2) & ~0x33333333);
+ val = ((val >> 4) & 0x0f0f0f0f) + ((val << 4) & ~0x0f0f0f0f);
+ val = ((val >> 8) & 0x00ff00ff) + ((val << 8) & ~0x00ff00ff);
+ return ((val >> 16) & 0x0000ffff) + ((val << 16) & ~0x0000ffff);
}
/**
Index: java/lang/Long.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Long.java,v
retrieving revision 1.19.2.2
diff -u -r1.19.2.2 Long.java
--- java/lang/Long.java 9 Oct 2004 23:12:26 -0000 1.19.2.2
+++ java/lang/Long.java 1 Nov 2004 15:52:21 -0000
@@ -566,7 +566,7 @@
* @param distance the number of bits by which to rotate
* @since 1.5
*/
- public static int rotateRight(long x, int distance)
+ public static long rotateRight(long x, int distance)
{
// This trick works because the shift operators implicitly mask
// the shift count.
Index: java/util/Collections.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Collections.java,v
retrieving revision 1.28.2.4
diff -u -r1.28.2.4 Collections.java
--- java/util/Collections.java 15 Aug 2004 07:59:51 -0000 1.28.2.4
+++ java/util/Collections.java 1 Nov 2004 15:52:22 -0000
@@ -405,7 +405,7 @@
/**
* There are no entries.
*/
- public Set<Entry<K, V>> entrySet()
+ public Set<Map.Entry<K, V>> entrySet()
{
return EMPTY_SET;
}
@@ -1563,7 +1563,7 @@
/**
* Cache the entry set.
*/
- private transient Set<BasicMapEntry<K, V>> entries;
+ private transient Set<AbstractMap.BasicMapEntry<K, V>> entries;
/**
* Construct a singleton.
@@ -1579,7 +1579,7 @@
/**
* There is a single immutable entry.
*/
- public Set<BasicMapEntry<K, V>> entrySet()
+ public Set<AbstractMap.BasicMapEntry<K, V>> entrySet()
{
if (entries == null)
entries = singleton(new AbstractMap.BasicMapEntry<K, V>(k, v)
@@ -2467,14 +2467,14 @@
if (entries == null)
synchronized (mutex)
{
- entries = new SynchronizedSet<K, V>(mutex, m.entrySet())
+ entries = new SynchronizedSet<Map.Entry<K, V>>(mutex, m.entrySet())
{
public Iterator<Map.Entry<K, V>> iterator()
{
synchronized (super.mutex)
{
- return new SynchronizedIterator<K, V>(super.mutex,
- c.iterator())
+ return new SynchronizedIterator<Map.Entry<K,
V>>(super.mutex,
+
c.iterator())
{
public Map.Entry<K, V> next()
{
@@ -3471,7 +3471,7 @@
throw new UnsupportedOperationException();
}
- public Map.Entry<K, V> remove(Object o)
+ public V remove(Object o)
{
throw new UnsupportedOperationException();
}
Index: java/util/HashMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/HashMap.java,v
retrieving revision 1.28.2.2
diff -u -r1.28.2.2 HashMap.java
--- java/util/HashMap.java 15 Aug 2004 07:59:52 -0000 1.28.2.2
+++ java/util/HashMap.java 1 Nov 2004 15:52:22 -0000
@@ -380,7 +380,8 @@
*/
public void putAll(Map<? extends K, ? extends V> m)
{
- Iterator<? extends K, ? extends V> itr = m.entrySet().iterator();
+ Iterator<Map.Entry<? extends K, ? extends V>> itr
+ = m.entrySet().iterator();
while (itr.hasNext())
{
Map.Entry<? extends K, ? extends V> e = itr.next();
@@ -709,7 +710,8 @@
*/
void putAllInternal(Map<? extends K, ? extends V> m)
{
- Iterator<? extends K, ? extends V> itr = m.entrySet().iterator();
+ Iterator<Map.Entry<? extends K, ? extends V>> itr
+ = m.entrySet().iterator();
size = 0;
while (itr.hasNext())
{
@@ -815,7 +817,7 @@
*
* @author Jon Zeppieri
*/
- private final class HashIterator implements Iterator
+ private final class HashIterator<T> implements Iterator<T>
{
/**
* The type of this Iterator: address@hidden #KEYS}, address@hidden
#VALUES},
Index: java/util/Hashtable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Hashtable.java,v
retrieving revision 1.32
diff -u -r1.32 Hashtable.java
--- java/util/Hashtable.java 22 Apr 2004 11:24:39 -0000 1.32
+++ java/util/Hashtable.java 1 Nov 2004 15:52:23 -0000
@@ -99,8 +99,8 @@
* @since 1.0
* @status updated to 1.4
*/
-public class Hashtable extends Dictionary
- implements Map, Cloneable, Serializable
+public class Hashtable<K, V> extends Dictionary<K, V>
+ implements Map<K, V>, Cloneable, Serializable
{
// WARNING: Hashtable is a CORE class in the bootstrap cycle. See the
// comments in vm/reference/java/lang/Runtime for implications of this fact.
@@ -144,7 +144,7 @@
* Array containing the actual key-value mappings.
*/
// Package visible for use by nested classes.
- transient HashEntry[] buckets;
+ transient HashEntry<K, V>[] buckets;
/**
* Counts the number of modifications this Hashtable has undergone, used
@@ -162,34 +162,35 @@
/**
* The cache for address@hidden #keySet()}.
*/
- private transient Set keys;
+ private transient Set<K> keys;
/**
* The cache for address@hidden #values()}.
*/
- private transient Collection values;
+ private transient Collection<V> values;
/**
* 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
* pair. A Hashtable Entry is identical to a HashMap Entry, except that
* `null' is not allowed for keys and values.
*/
- private static final class HashEntry extends AbstractMap.BasicMapEntry
+ private static final class HashEntry<K, V>
+ extends AbstractMap.BasicMapEntry<K, V>
{
/** The next entry in the linked list. */
- HashEntry next;
+ HashEntry<K, V> next;
/**
* Simple constructor.
* @param key the key, already guaranteed non-null
* @param value the value, already guaranteed non-null
*/
- HashEntry(Object key, Object value)
+ HashEntry(K key, V value)
{
super(key, value);
}
@@ -200,7 +201,7 @@
* @return the prior value
* @throws NullPointerException if <code>newVal</code> is null
*/
- public Object setValue(Object newVal)
+ public V setValue(V newVal)
{
if (newVal == null)
throw new NullPointerException();
@@ -231,7 +232,7 @@
* to or from `null'.
* @since 1.2
*/
- public Hashtable(Map m)
+ public Hashtable(Map<? extends K, ? extends V> m)
{
this(Math.max(m.size() * 2, DEFAULT_CAPACITY), DEFAULT_LOAD_FACTOR);
putAll(m);
@@ -268,7 +269,7 @@
if (initialCapacity == 0)
initialCapacity = 1;
- buckets = new HashEntry[initialCapacity];
+ buckets = new HashEntry<K, V>[initialCapacity];
this.loadFactor = loadFactor;
threshold = (int) (initialCapacity * loadFactor);
}
@@ -300,9 +301,9 @@
* @see #elements()
* @see #keySet()
*/
- public Enumeration keys()
+ public Enumeration<K> keys()
{
- return new Enumerator(KEYS);
+ return new Enumerator<K>(KEYS);
}
/**
@@ -316,7 +317,7 @@
*/
public Enumeration elements()
{
- return new Enumerator(VALUES);
+ return new Enumerator<V>(VALUES);
}
/**
@@ -335,7 +336,7 @@
{
for (int i = buckets.length - 1; i >= 0; i--)
{
- HashEntry e = buckets[i];
+ HashEntry<K, V> e = buckets[i];
while (e != null)
{
if (value.equals(e.value))
@@ -347,7 +348,7 @@
// Must throw on null argument even if the table is empty
if (value == null)
throw new NullPointerException();
-
+
return false;
}
@@ -382,7 +383,7 @@
public synchronized boolean containsKey(Object key)
{
int idx = hash(key);
- HashEntry e = buckets[idx];
+ HashEntry<K, V> e = buckets[idx];
while (e != null)
{
if (key.equals(e.key))
@@ -402,10 +403,10 @@
* @see #put(Object, Object)
* @see #containsKey(Object)
*/
- public synchronized Object get(Object key)
+ public synchronized V get(Object key)
{
int idx = hash(key);
- HashEntry e = buckets[idx];
+ HashEntry<K, V> e = buckets[idx];
while (e != null)
{
if (key.equals(e.key))
@@ -427,10 +428,10 @@
* @see #get(Object)
* @see Object#equals(Object)
*/
- public synchronized Object put(Object key, Object value)
+ public synchronized V put(K key, V value)
{
int idx = hash(key);
- HashEntry e = buckets[idx];
+ HashEntry<K, V> e = buckets[idx];
// Check if value is null since it is not permitted.
if (value == null)
@@ -441,7 +442,7 @@
if (key.equals(e.key))
{
// Bypass e.setValue, since we already know value is non-null.
- Object r = e.value;
+ V r = e.value;
e.value = value;
return r;
}
@@ -460,7 +461,7 @@
idx = hash(key);
}
- e = new HashEntry(key, value);
+ e = new HashEntry<K, V>(key, value);
e.next = buckets[idx];
buckets[idx] = e;
@@ -476,11 +477,11 @@
* @param key the key used to locate the value to remove
* @return whatever the key mapped to, if present
*/
- public synchronized Object remove(Object key)
+ public synchronized 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)
{
@@ -508,17 +509,20 @@
* @param m the map to be hashed into this
* @throws NullPointerException if m is null, or contains null keys or values
*/
- public synchronized void putAll(Map m)
+ public synchronized void putAll(Map<? extends K, ? extends V> m)
{
- Iterator itr = m.entrySet().iterator();
+ Iterator<Map.Entry<? 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
+ = (Map.Entry<? extends K, ? extends V>) 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
@@ -549,16 +553,16 @@
*/
public synchronized Object clone()
{
- Hashtable copy = null;
+ Hashtable<K, V> copy = null;
try
{
- copy = (Hashtable) super.clone();
+ copy = (Hashtable<K, V>) super.clone();
}
catch (CloneNotSupportedException x)
{
// This is impossible.
}
- copy.buckets = new HashEntry[buckets.length];
+ copy.buckets = new HashEntry<K, V>[buckets.length];
copy.putAllInternal(this);
// Clear the caches.
copy.keys = null;
@@ -582,7 +586,8 @@
// Since we are already synchronized, and entrySet().iterator()
// would repeatedly re-lock/release the monitor, we directly use the
// unsynchronized HashIterator instead.
- Iterator entries = new HashIterator(ENTRIES);
+ Iterator<Map.Entry<? extends K, ? extends V>> entries
+ = new HashIterator<Map.Entry<? extends K, ? extends V>>(ENTRIES);
StringBuffer r = new StringBuffer("{");
for (int pos = size; pos > 0; pos--)
{
@@ -609,22 +614,22 @@
* @see #entrySet()
* @since 1.2
*/
- public Set keySet()
+ public Set<K> keySet()
{
if (keys == null)
{
// Create a synchronized AbstractSet with custom implementations of
// those methods that can be overridden easily and efficiently.
- Set r = new AbstractSet()
+ Set<K> r = new AbstractSet<K>()
{
public int size()
{
return size;
}
- public Iterator iterator()
+ public Iterator<K> iterator()
{
- return new HashIterator(KEYS);
+ return new HashIterator<K>(KEYS);
}
public void clear()
@@ -646,7 +651,7 @@
};
// We must specify the correct object to synchronize upon, hence the
// use of a non-public API
- keys = new Collections.SynchronizedSet(this, r);
+ keys = new Collections.SynchronizedSet<K>(this, r);
}
return keys;
}
@@ -667,22 +672,22 @@
* @see #entrySet()
* @since 1.2
*/
- 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.
- Collection r = new AbstractCollection()
+ Collection<V> r = new AbstractCollection<V>()
{
public int size()
{
return size;
}
- public Iterator iterator()
+ public Iterator<V> iterator()
{
- return new HashIterator(VALUES);
+ return new HashIterator<V>(VALUES);
}
public void clear()
@@ -692,7 +697,7 @@
};
// We must specify the correct object to synchronize upon, hence the
// use of a non-public API
- values = new Collections.SynchronizedCollection(this, r);
+ values = new Collections.SynchronizedCollection<V>(this, r);
}
return values;
}
@@ -719,22 +724,22 @@
* @see Map.Entry
* @since 1.2
*/
- 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.
- Set r = new AbstractSet()
+ Set<Map.Entry<K, V>> r = new AbstractSet<Map.Entry<K, V>>()
{
public int size()
{
return size;
}
- public Iterator iterator()
+ public Iterator<Map.Entry<K, V>> iterator()
{
- return new HashIterator(ENTRIES);
+ return new HashIterator<Map.Entry<K, V>>(ENTRIES);
}
public void clear()
@@ -749,7 +754,7 @@
public boolean remove(Object o)
{
- HashEntry e = getEntry(o);
+ HashEntry<K, V> e = getEntry(o);
if (e != null)
{
Hashtable.this.remove(e.key);
@@ -760,7 +765,7 @@
};
// We must specify the correct object to synchronize upon, hence the
// use of a non-public API
- entries = new Collections.SynchronizedSet(this, r);
+ entries = new Collections.SynchronizedSet<Map.Entry<K, V>>(this, r);
}
return entries;
}
@@ -778,7 +783,7 @@
*/
public boolean equals(Object o)
{
- // no need to synchronize, entrySet().equals() does that
+ // No need to synchronize, entrySet().equals() does that.
if (o == this)
return true;
if (!(o instanceof Map))
@@ -799,7 +804,7 @@
// Since we are already synchronized, and entrySet().iterator()
// would repeatedly re-lock/release the monitor, we directly use the
// unsynchronized HashIterator instead.
- Iterator itr = new HashIterator(ENTRIES);
+ Iterator<Map.Entry<K, V>> itr = new HashIterator<Map.Entry<K, V>>(ENTRIES);
int hashcode = 0;
for (int pos = size; pos > 0; pos--)
hashcode += itr.next().hashCode();
@@ -815,7 +820,7 @@
* @return the bucket number
* @throws NullPointerException if key is null
*/
- private int hash(Object key)
+ private int hash(K key)
{
// Note: Inline Math.abs here, for less method overhead, and to avoid
// a bootstrap dependency, since Math relies on native methods.
@@ -832,16 +837,16 @@
* @see #entrySet()
*/
// Package visible, for use in nested classes.
- HashEntry getEntry(Object o)
+ HashEntry<K, V> getEntry(Object o)
{
- if (! (o instanceof Map.Entry))
+ if (! (o instanceof Map.Entry<K, V>))
return null;
- Object key = ((Map.Entry) o).getKey();
+ K key = ((Map.Entry<K, V>) o).getKey();
if (key == null)
return null;
int idx = hash(key);
- HashEntry e = buckets[idx];
+ HashEntry<K, V> e = buckets[idx];
while (e != null)
{
if (o.equals(e))
@@ -858,18 +863,20 @@
*
* @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<Map.Entry<? 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<? extends K, ? extends V> e
+ = (Map.Entry<? extends K, ? extends V>) itr.next();
+ K key = e.getKey();
int idx = hash(key);
- HashEntry he = new HashEntry(key, e.getValue());
+ HashEntry<K, V> he = new HashEntry<K, V>(key, e.getValue());
he.next = buckets[idx];
buckets[idx] = he;
}
@@ -888,19 +895,19 @@
*/
protected 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<K, V> dest = buckets[idx];
if (dest != null)
{
@@ -913,7 +920,7 @@
buckets[idx] = e;
}
- HashEntry next = e.next;
+ HashEntry<K, V> next = e.next;
e.next = null;
e = next;
}
@@ -941,10 +948,10 @@
// Since we are already synchronized, and entrySet().iterator()
// would repeatedly re-lock/release the monitor, we directly use the
// unsynchronized HashIterator instead.
- Iterator it = new HashIterator(ENTRIES);
+ Iterator<Map.Entry<K, V>> it = new HashIterator<Map.Entry<K, V>>(ENTRIES);
while (it.hasNext())
{
- HashEntry entry = (HashEntry) it.next();
+ HashEntry<K, V> entry = (HashEntry<K, V>) it.next();
s.writeObject(entry.key);
s.writeObject(entry.value);
}
@@ -968,7 +975,7 @@
s.defaultReadObject();
// Read and use capacity.
- buckets = new HashEntry[s.readInt()];
+ buckets = new HashEntry<K, V>[s.readInt()];
int len = s.readInt();
// Read and use key/value pairs.
@@ -988,7 +995,7 @@
*
* @author Jon Zeppieri
*/
- private final class HashIterator implements Iterator
+ private final class HashIterator<T> implements Iterator<T>
{
/**
* The type of this Iterator: address@hidden #KEYS}, address@hidden
#VALUES},
@@ -1004,13 +1011,13 @@
/** Current index in the physical hash table. */
int idx = buckets.length;
/** The last Entry returned by a next() call. */
- HashEntry last;
+ HashEntry<K, V> last;
/**
* The next entry that should be returned by next(). It is set to something
* if we're iterating through a bucket that contains multiple linked
* entries. It is null if next() needs to find a new bucket.
*/
- HashEntry next;
+ HashEntry<K, V> next;
/**
* Construct a new HashIterator with the supplied type.
@@ -1039,14 +1046,14 @@
* @throws ConcurrentModificationException if the hashtable was modified
* @throws NoSuchElementException if there is none
*/
- public Object next()
+ public T next()
{
if (knownMod != modCount)
throw new ConcurrentModificationException();
if (count == 0)
throw new NoSuchElementException();
count--;
- HashEntry e = next;
+ HashEntry<K, V> e = next;
while (e == null)
e = buckets[--idx];
@@ -1094,7 +1101,7 @@
*
* @author Jon Zeppieri
*/
- private final class Enumerator implements Enumeration
+ private final class Enumerator<T> implements Enumeration<T>
{
/**
* The type of this Iterator: address@hidden #KEYS} or address@hidden
#VALUES}.
@@ -1109,7 +1116,7 @@
* set if we are iterating through a bucket with multiple entries, or null
* if we must look in the next bucket.
*/
- HashEntry next;
+ HashEntry<K, V> next;
/**
* Construct the enumeration.
@@ -1139,7 +1146,7 @@
if (count == 0)
throw new NoSuchElementException("Hashtable Enumerator");
count--;
- HashEntry e = next;
+ HashEntry<K, V> e = next;
while (e == null)
e = buckets[--idx];
Index: vm/reference/java/lang/reflect/Constructor.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/vm/reference/java/lang/reflect/Constructor.java,v
retrieving revision 1.11.2.1
diff -u -r1.11.2.1 Constructor.java
--- vm/reference/java/lang/reflect/Constructor.java 27 Aug 2004 00:05:03 -0000
1.11.2.1
+++ vm/reference/java/lang/reflect/Constructor.java 1 Nov 2004 15:52:23 -0000
@@ -259,4 +259,12 @@
int slot)
throws InstantiationException, IllegalAccessException,
InvocationTargetException;
+
+ /** FIXME
+ * @since 1.5
+ */
+ public TypeVariable<?>[] getTypeParameters()
+ {
+ return new TypeVariable<?>[0];
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cp-patches] [generics] Patch: FYI: minor fixes all over,
Tom Tromey <=