diff --git a/classpath/java/util/AbstractCollection.java b/classpath/java/util/AbstractCollection.java index bc4abfe7a5..5093b9a612 100644 --- a/classpath/java/util/AbstractCollection.java +++ b/classpath/java/util/AbstractCollection.java @@ -33,7 +33,7 @@ public abstract class AbstractCollection implements Collection { + this.getClass().getName()); } - public boolean contains(T element) { + public boolean contains(Object element) { if (element != null) { for (Iterator iter = iterator(); iter.hasNext();) { if (element.equals(iter.next())) { @@ -55,7 +55,7 @@ public abstract class AbstractCollection implements Collection { return size() == 0; } - public boolean remove(T element) { + public boolean remove(Object element) { throw new UnsupportedOperationException("remove(T) in " + this.getClass().getName()); } diff --git a/classpath/java/util/ArrayList.java b/classpath/java/util/ArrayList.java index 00482f5722..d6ca7d07d3 100644 --- a/classpath/java/util/ArrayList.java +++ b/classpath/java/util/ArrayList.java @@ -66,7 +66,7 @@ public class ArrayList implements List { return size; } - public boolean contains(T element) { + public boolean contains(Object element) { for (int i = 0; i < size; ++i) { if (equal(element, array[i])) { return true; @@ -145,7 +145,7 @@ public class ArrayList implements List { return v; } - public boolean remove(T element) { + public boolean remove(Object element) { for (int i = 0; i < size; ++i) { if (equal(element, array[i])) { remove(i); diff --git a/classpath/java/util/Arrays.java b/classpath/java/util/Arrays.java index af87139c8f..db41e6bddc 100644 --- a/classpath/java/util/Arrays.java +++ b/classpath/java/util/Arrays.java @@ -64,7 +64,7 @@ public class Arrays { throw new UnsupportedOperationException(); } - public boolean contains(T element) { + public boolean contains(Object element) { for (int i = 0; i < array.length; ++i) { if (equal(element, array[i])) { return true; @@ -93,7 +93,7 @@ public class Arrays { throw new UnsupportedOperationException(); } - public boolean remove(T element) { + public boolean remove(Object element) { throw new UnsupportedOperationException(); } diff --git a/classpath/java/util/Collection.java b/classpath/java/util/Collection.java index c2d68500c7..aa8eee6d89 100644 --- a/classpath/java/util/Collection.java +++ b/classpath/java/util/Collection.java @@ -21,7 +21,7 @@ public interface Collection extends Iterable { public boolean addAll(Collection collection); - public boolean remove(T element); + public boolean remove(Object element); public S[] toArray(S[] array); diff --git a/classpath/java/util/Collections.java b/classpath/java/util/Collections.java index d2391d7435..619a4c5c61 100644 --- a/classpath/java/util/Collections.java +++ b/classpath/java/util/Collections.java @@ -97,7 +97,7 @@ public class Collections { return size() == 0; } - public boolean contains(T e) { + public boolean contains(Object e) { synchronized (lock) { return collection.contains(e); } } @@ -109,8 +109,8 @@ public class Collections { synchronized (lock) { return this.collection.addAll(collection); } } - public boolean remove(T e) { - synchronized (lock) { return collection.remove(e); } + public boolean remove(Object e) { + synchronized (lock) { return collection.remove((T)e); } } public T[] toArray(T[] array) { @@ -152,7 +152,7 @@ public class Collections { public Set> entrySet() { synchronized (lock) { return new SynchronizedSet>(lock, map.entrySet()); } } - public V get(K key) { + public V get(Object key) { synchronized (lock) { return map.get(key); } } public boolean isEmpty() { @@ -167,7 +167,7 @@ public class Collections { public void putAll(Map elts) { synchronized (lock) { map.putAll(elts); } } - public V remove(K key) { + public V remove(Object key) { synchronized (lock) { return map.remove(key); } } public int size() { @@ -283,7 +283,7 @@ public class Collections { throw new UnsupportedOperationException("not supported"); } - public boolean contains(T element) { + public boolean contains(Object element) { return inner.contains(element); } @@ -295,7 +295,7 @@ public class Collections { return inner.iterator(); } - public boolean remove(T element) { + public boolean remove(Object element) { throw new UnsupportedOperationException("not supported"); } diff --git a/classpath/java/util/HashMap.java b/classpath/java/util/HashMap.java index 2197f9838d..dd6eb85f61 100644 --- a/classpath/java/util/HashMap.java +++ b/classpath/java/util/HashMap.java @@ -337,6 +337,10 @@ public class HashMap implements Map { return change; } + public boolean remove(Object o) { + return (o instanceof Entry) ? remove((Entry)o) : false; + } + public boolean remove(Entry e) { return removeCell(e.getKey()) != null; } @@ -416,7 +420,7 @@ public class HashMap implements Map { throw new UnsupportedOperationException(); } - public boolean remove(V value) { + public boolean remove(Object value) { throw new UnsupportedOperationException(); } diff --git a/classpath/java/util/HashSet.java b/classpath/java/util/HashSet.java index 6e6e96dd5d..b89c317a35 100644 --- a/classpath/java/util/HashSet.java +++ b/classpath/java/util/HashSet.java @@ -36,7 +36,7 @@ public class HashSet implements Set { return map.isEmpty(); } - public boolean contains(T element) { + public boolean contains(Object element) { return map.containsKey(element); } @@ -50,7 +50,7 @@ public class HashSet implements Set { return change; } - public boolean remove(T element) { + public boolean remove(Object element) { return map.remove(element) != Value; } diff --git a/classpath/java/util/Hashtable.java b/classpath/java/util/Hashtable.java index b08b4c3b67..978847a6b7 100644 --- a/classpath/java/util/Hashtable.java +++ b/classpath/java/util/Hashtable.java @@ -48,7 +48,7 @@ public class Hashtable implements Map { return map.containsValue(value); } - public synchronized V get(K key) { + public synchronized V get(Object key) { return map.get(key); } @@ -60,7 +60,7 @@ public class Hashtable implements Map { map.putAll(elts); } - public synchronized V remove(K key) { + public synchronized V remove(Object key) { return map.remove(key); } diff --git a/classpath/java/util/IdentityHashMap.java b/classpath/java/util/IdentityHashMap.java index 123c26990e..ce6f34cbe9 100644 --- a/classpath/java/util/IdentityHashMap.java +++ b/classpath/java/util/IdentityHashMap.java @@ -37,7 +37,7 @@ public class IdentityHashMap implements Map { return map.containsValue(value); } - public V get(K key) { + public V get(Object key) { return map.get(key); } @@ -49,7 +49,7 @@ public class IdentityHashMap implements Map { map.putAll(elts); } - public V remove(K key) { + public V remove(Object key) { return map.remove(key); } diff --git a/classpath/java/util/LinkedList.java b/classpath/java/util/LinkedList.java index a9f4c442ce..657d245997 100644 --- a/classpath/java/util/LinkedList.java +++ b/classpath/java/util/LinkedList.java @@ -60,7 +60,7 @@ public class LinkedList implements List { } } - private Cell find(T element) { + private Cell find(Object element) { for (Cell c = front; c != null; c = c.next) { if (equal(c.value, element)) { return c; @@ -93,7 +93,7 @@ public class LinkedList implements List { return size; } - public boolean contains(T element) { + public boolean contains(Object element) { return find(element) != null; } @@ -186,7 +186,7 @@ public class LinkedList implements List { } } - public boolean remove(T element) { + public boolean remove(Object element) { Cell c = find(element); if (c == null) { return false; diff --git a/classpath/java/util/TreeSet.java b/classpath/java/util/TreeSet.java index eaff92106a..4940eb0d22 100644 --- a/classpath/java/util/TreeSet.java +++ b/classpath/java/util/TreeSet.java @@ -60,7 +60,7 @@ public class TreeSet extends AbstractSet implements Collection { } } - public boolean remove(T value) { + public boolean remove(Object value) { PersistentSet.Path> p = set.find(new Cell(value, null)); if (p.fresh()) { return false; @@ -85,7 +85,7 @@ public class TreeSet extends AbstractSet implements Collection { return size == 0; } - public boolean contains(T value) { + public boolean contains(Object value) { return !set.find(new Cell(value, null)).fresh(); } diff --git a/classpath/java/util/Vector.java b/classpath/java/util/Vector.java index 21bd896b7c..f06f58ecbc 100644 --- a/classpath/java/util/Vector.java +++ b/classpath/java/util/Vector.java @@ -29,7 +29,7 @@ public class Vector implements List { return list.size(); } - public synchronized boolean contains(T element) { + public synchronized boolean contains(Object element) { return list.contains(element); } @@ -85,7 +85,7 @@ public class Vector implements List { remove(index); } - public synchronized boolean remove(T element) { + public synchronized boolean remove(Object element) { return list.remove(element); } diff --git a/classpath/java/util/WeakHashMap.java b/classpath/java/util/WeakHashMap.java index 8a8da9c1c0..2dc5c9fceb 100644 --- a/classpath/java/util/WeakHashMap.java +++ b/classpath/java/util/WeakHashMap.java @@ -54,7 +54,7 @@ public class WeakHashMap implements Map { return map.containsValue(value); } - public V get(K key) { + public V get(Object key) { poll(); return map.get(key); } @@ -68,7 +68,7 @@ public class WeakHashMap implements Map { map.putAll(elts); } - public V remove(K key) { + public V remove(Object key) { poll(); return map.remove(key); }