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 cfde456aab..aa8eee6d89 100644 --- a/classpath/java/util/Collection.java +++ b/classpath/java/util/Collection.java @@ -15,13 +15,13 @@ public interface Collection extends Iterable { public boolean isEmpty(); - public boolean contains(T element); + public boolean contains(Object element); public boolean add(T element); 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 134c481322..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) { @@ -143,16 +143,16 @@ public class Collections { public void clear() { synchronized (lock) { map.clear(); } } - public boolean containsKey(K key) { + public boolean containsKey(Object key) { synchronized (lock) { return map.containsKey(key); } } - public boolean containsValue(V value) { + public boolean containsValue(Object value) { synchronized (lock) { return map.containsValue(value); } } 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 43ee2e8148..dd6eb85f61 100644 --- a/classpath/java/util/HashMap.java +++ b/classpath/java/util/HashMap.java @@ -107,7 +107,7 @@ public class HashMap implements Map { array = newArray; } - private Cell find(K key) { + private Cell find(Object key) { if (array != null) { int index = helper.hash(key) & (array.length - 1); for (Cell c = array[index]; c != null; c = c.next()) { @@ -158,20 +158,29 @@ public class HashMap implements Map { return c; } - public boolean containsKey(K key) { + public boolean containsKey(Object key) { return find(key) != null; } - public boolean containsValue(V value) { - return values().contains(value); + public boolean containsValue(Object value) { + if (array != null) { + int index = array.length - 1; + for (Cell c = array[index]; c != null; c = c.next()) { + if (helper.equal(value, c.getValue())) { + return true; + } + } + } + + return false; } - public V get(K key) { + public V get(Object key) { Cell c = find(key); return (c == null ? null : c.getValue()); } - public Cell removeCell(K key) { + public Cell removeCell(Object key) { Cell old = null; if (array != null) { int index = helper.hash(key) & (array.length - 1); @@ -213,8 +222,8 @@ public class HashMap implements Map { } } - public V remove(K key) { - Cell c = removeCell(key); + public V remove(Object key) { + Cell c = removeCell((K)key); return (c == null ? null : c.getValue()); } @@ -314,8 +323,8 @@ public class HashMap implements Map { return HashMap.this.isEmpty(); } - public boolean contains(Entry e) { - return containsKey(e.getKey()); + public boolean contains(Object o) { + return (o instanceof Entry) ? containsKey(((Entry)o).getKey()) : false; } public boolean add(Entry e) { @@ -328,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; } @@ -354,7 +367,7 @@ public class HashMap implements Map { return HashMap.this.isEmpty(); } - public boolean contains(K key) { + public boolean contains(Object key) { return containsKey(key); } @@ -368,7 +381,7 @@ public class HashMap implements Map { return change; } - public boolean remove(K key) { + public boolean remove(Object key) { return removeCell(key) != null; } @@ -395,7 +408,7 @@ public class HashMap implements Map { return HashMap.this.isEmpty(); } - public boolean contains(V value) { + public boolean contains(Object value) { return containsValue(value); } @@ -407,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 8ae75941a3..978847a6b7 100644 --- a/classpath/java/util/Hashtable.java +++ b/classpath/java/util/Hashtable.java @@ -40,15 +40,15 @@ public class Hashtable implements Map { return map.size(); } - public synchronized boolean containsKey(K key) { + public synchronized boolean containsKey(Object key) { return map.containsKey(key); } - public synchronized boolean containsValue(V value) { + public synchronized boolean containsValue(Object value) { 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 7a86c5a192..ce6f34cbe9 100644 --- a/classpath/java/util/IdentityHashMap.java +++ b/classpath/java/util/IdentityHashMap.java @@ -29,15 +29,15 @@ public class IdentityHashMap implements Map { return map.size(); } - public boolean containsKey(K key) { + public boolean containsKey(Object key) { return map.containsKey(key); } - public boolean containsValue(V value) { + public boolean containsValue(Object value) { 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/Map.java b/classpath/java/util/Map.java index 0b5fa550b2..47edee351e 100644 --- a/classpath/java/util/Map.java +++ b/classpath/java/util/Map.java @@ -15,17 +15,17 @@ public interface Map { public int size(); - public boolean containsKey(K key); + public boolean containsKey(Object obj); - public boolean containsValue(V value); + public boolean containsValue(Object obj); - public V get(K key); + public V get(Object key); public V put(K key, V value); public void putAll(Map elts); - public V remove(K key); + public V remove(Object key); public void clear(); 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 1618d58907..2dc5c9fceb 100644 --- a/classpath/java/util/WeakHashMap.java +++ b/classpath/java/util/WeakHashMap.java @@ -44,17 +44,17 @@ public class WeakHashMap implements Map { return map.size(); } - public boolean containsKey(K key) { + public boolean containsKey(Object key) { poll(); return map.containsKey(key); } - public boolean containsValue(V value) { + public boolean containsValue(Object value) { poll(); 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); } diff --git a/makefile b/makefile index 1159306512..98694b3d1c 100644 --- a/makefile +++ b/makefile @@ -334,6 +334,13 @@ test: build $(executable) $(mode) "$(flags)" \ $(call class-names,$(test-build),$(test-classes)) +.PHONY: tarball +tarball: + @echo "creating build/avian-$(version).tar.bz2" + @mkdir -p build + (cd .. && tar --exclude=build --exclude='.*' --exclude='*~' -cjf \ + avian/build/avian-$(version).tar.bz2 avian) + .PHONY: javadoc javadoc: javadoc -sourcepath classpath -d build/javadoc -subpackages java \