[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: java.util and vm/ref patch
From: |
Mark Wielaard |
Subject: |
Re: java.util and vm/ref patch |
Date: |
26 Mar 2002 00:27:44 +0100 |
Hi,
On Mon, 2002-03-25 at 14:44, Brian Jones wrote:
> If someone has the time, these patches need to be looked over to see
> if all or parts of them should be committed. It's part of the Intel
> batch we have paperwork in place for but were not broken out on
> Savannah previously. Everything else has already been committed or
> looked over.
diff -w -uNr java/util/AbstractList.java
../classpath/java/util/AbstractList.java
--- java/util/AbstractList.java Thu Oct 25 15:34:20 2001
+++ ../classpath/java/util/AbstractList.java Wed Mar 20 18:09:04 2002
@@ -309,10 +309,10 @@
public Object next()
{
checkMod();
- if (pos == size)
+ if (pos >= size)
throw new NoSuchElementException();
last = pos++;
- return get(pos);
+ return get(last);
}
Bryce checked in a similar patch.
diff -w -uNr java/util/Arrays.java ../classpath/java/util/Arrays.java
--- java/util/Arrays.java Thu Oct 25 15:34:20 2001
+++ ../classpath/java/util/Arrays.java Wed Mar 20 18:09:04 2002
@@ -2420,7 +2420,7 @@
{
int size = a.length;
for (int i = 0; i < size; i++)
- if (equals(o, a[i]))
+ if (this.equals(o, a[i]))
return i;
return -1;
}
@@ -2429,7 +2429,7 @@
{
int i = a.length;
while (--i >= 0)
- if (equals(o, a[i]))
+ if (this.equals(o, a[i]))
return i;
return -1;
}
I checked in such a patch based on a bug report from Takashi Okamoto.
diff -w -uNr java/util/Hashtable.java ../classpath/java/util/Hashtable.java
--- java/util/Hashtable.java Thu Oct 25 15:34:20 2001
+++ ../classpath/java/util/Hashtable.java Wed Mar 20 18:09:04 2002
@@ -501,7 +501,6 @@
public synchronized void putAll(Map m)
{
Iterator itr = m.entrySet().iterator();
-
for (int msize = m.size(); msize > 0; msize--)
{
Map.Entry e = (Map.Entry) itr.next();
@@ -548,6 +547,7 @@
{
// This is impossible.
}
+ copy.size = 0;
copy.buckets = new HashEntry[buckets.length];
copy.putAll(this);
// Clear the caches.
@@ -932,6 +932,7 @@
// Read and use capacity.
buckets = new HashEntry[s.readInt()];
int len = s.readInt();
+ size = 0;
// Read and use key/value pairs.
// TODO: should we be defensive programmers, and check for illegal
nulls?
@@ -1007,7 +1008,8 @@
throw new ConcurrentModificationException();
if (count == 0)
throw new NoSuchElementException();
- count--;
+ --count;
+
HashEntry e = next;
while (e == null)
@@ -1015,6 +1017,7 @@
next = e.next;
last = e;
+
if (type == VALUES)
return e.value;
if (type == KEYS)
@@ -1037,7 +1040,8 @@
Hashtable.this.remove(last.key);
last = null;
- knownMod++;
+ --count;
+ ++knownMod;
}
} // class HashIterator
The size = 0 parts seem to be necessary, but I don't get the other parts.
diff -w -uNr java/util/LinkedList.java
../classpath/java/util/LinkedList.java
--- java/util/LinkedList.java Thu Oct 25 15:34:20 2001
+++ ../classpath/java/util/LinkedList.java Wed Mar 20 18:09:04 2002
@@ -329,7 +329,7 @@
{
modCount++;
size++;
- if (size == 0)
+ if (size == 1)
first = last = e;
else
{
@@ -727,6 +727,7 @@
{
s.defaultReadObject();
int i = s.readInt();
+ size = 0;
while (--i >= 0)
addLastEntry(new Entry(s.readObject()));
}
A similar fix for the first part (addLastEntry) was checked in by Bryce.
The size = 0 part seems necessary.
Skipping analysis of ResourceBundle for now.
diff -w -uNr java/util/WeakHashMap.java
../classpath/java/util/WeakHashMap.java
--- java/util/WeakHashMap.java Wed Oct 31 09:00:30 2001
+++ ../classpath/java/util/WeakHashMap.java Wed Mar 20 18:09:04 2002
@@ -472,7 +472,7 @@
*/
WeakEntry getEntry()
{
- final Object key = get();
+ final Object key = this.get();
if (key == null)
return null;
return new WeakEntry(key);
I checked in a patch based on a bug report from Takashi Okamoto.
diff -w -uNr java/util/jar/Manifest.java
../classpath/java/util/jar/Manifest.java
--- java/util/jar/Manifest.java Mon Dec 3 14:53:26 2001
+++ ../classpath/java/util/jar/Manifest.java Wed Mar 20 18:09:04 2002
@@ -163,7 +163,8 @@
private static void read_main_section(Attributes attr,
BufferedReader br) throws IOException
{
- read_version_info(attr, br);
+ // version info isn't mandatory at the beginning in jar spec.
+ // read_version_info(attr, br);
read_attributes(attr, br);
}
Just checked in a similar patch.
Summary for java.util - two size = 0 fixes seems to be needed.
The ResourceBundle changes should be checked.
Cheers,
Mark