Re: java.util and vm/ref patch

2002-03-25 Thread Mark Wielaard

Hi,

--- java/util/jar/Manifest.java Mon Dec  3 14:53:26 2001
+++ ../classpath/java/util/jar/Manifest.javaWed 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);
   }
 
Actually according to (both the old and new) spec the first Main
attribute must be the Manifest-Version and it is mandatory. Which tool
creates Manifest files that do not follow this?
http://docs.iplanet.com/docs/manuals/signedobj/jarfile/jar.htm#426027
http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Manifest%20Specification

But it probably cannot hurt to accept such faulty Manifest files.
I have checked in the following:

2002-03-25  Mark Wielaard  [EMAIL PROTECTED]

  * java/util/jar/Attributes.java (putValue(Name,String)): Make package
  private.
  * java/util/Manifest.java (read_main_section): Don't require 
  Manifest-Version info, set to 0.0 when not found.

Cheers,

Mark


Index: java/util/jar/Attributes.java
===
RCS file: /cvsroot/classpath/classpath/java/util/jar/Attributes.java,v
retrieving revision 1.6
diff -u -r1.6 Attributes.java
--- java/util/jar/Attributes.java	22 Jan 2002 22:27:01 -	1.6
+++ java/util/jar/Attributes.java	25 Mar 2002 20:49:24 -
@@ -430,7 +430,7 @@
* @returns the old value of the attribute name or null if it didn't exist
* yet
*/
-  private String putValue(Name name, String value)
+  String putValue(Name name, String value)
   {
 return (String) put(name, value);
   }
Index: java/util/jar/Manifest.java
===
RCS file: /cvsroot/classpath/classpath/java/util/jar/Manifest.java,v
retrieving revision 1.6
diff -u -r1.6 Manifest.java
--- java/util/jar/Manifest.java	22 Jan 2002 22:27:01 -	1.6
+++ java/util/jar/Manifest.java	25 Mar 2002 20:49:24 -
@@ -174,10 +174,19 @@
   private static void read_main_section(Attributes attr,
 	BufferedReader br) throws IOException
   {
-read_version_info(attr, br);
+// According to the spec we should actually call read_version_info() here.
 read_attributes(attr, br);
+// Explicitly set Manifest-Version attribute if not set in Main
+// attributes of Manifest.
+if (attr.getValue(Attributes.Name.MANIFEST_VERSION) == null)
+	attr.putValue(Attributes.Name.MANIFEST_VERSION, 0.0);
   }
 
+  /**
+   * Pedantic method that requires the next attribute in the Manifest to be
+   * the Manifest-Version. This follows the Manifest spec closely but
+   * reject some jar Manifest files out in the wild.
+   */
   private static void read_version_info(Attributes attr,
 	BufferedReader br) throws IOException
   {
@@ -185,7 +194,7 @@
 try
   {
 	String value = expect_header(version_header, br);
-	attr.putValue(version_header, value);
+	attr.putValue(Attributes.Name.MANIFEST_VERSION, value);
   }
 catch (IOException ioe)
   {



Re: java.util and vm/ref patch

2002-03-25 Thread Mark Wielaard

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.javaWed 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.javaThu 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.javaWed Mar 20 18:09:04 2002
@@ -163,7 +163,8 @@
   private static void read_main_section(Attributes attr,
   

Re: java.util and vm/ref patch

2002-03-25 Thread Mark Wielaard

Hi,

Quickly going through the vm.diff.

- I added some of the changes to java.lang.Class already.
- java.lang.Runtime ShutdownHooks have already added by Eric.
- Throwable changes are irrelevant with latest Throwable from CVS.
- java.lang.Thread (contextClassLoader) changes have gone in.
- The java.lang.reflect.Method changes have already been committed.

Summary - it might be a good idea to look at Class, VMClassLoader and
SystemClassLoader for things we missed. But mostly this is done.

Cheers,

Mark

___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath



Re: java.util and vm/ref patch

2002-03-25 Thread Brian Jones

Mark Wielaard [EMAIL PROTECTED] writes:

 Hi,
 
 Quickly going through the vm.diff.
 
 - I added some of the changes to java.lang.Class already.
 - java.lang.Runtime ShutdownHooks have already added by Eric.
 - Throwable changes are irrelevant with latest Throwable from CVS.
 - java.lang.Thread (contextClassLoader) changes have gone in.
 - The java.lang.reflect.Method changes have already been committed.
 
 Summary - it might be a good idea to look at Class, VMClassLoader and
 SystemClassLoader for things we missed. But mostly this is done.

Okay,

I'm pretty bummed about the state of Mauve in helping to make it
easier to prove something works correctly in that so many tests are
simply missing.  This is where I'll be spending most of my energy in
the forseeable future.   I'm working on the beans api testing now mostly
so I can learn something about it.  I can see now that the measures I
felt were sort of draconian on the Jikes list with respect to patches
may be needed for Classpath as well just to help build up the base of
tests available.

Brian
-- 
Brian Jones [EMAIL PROTECTED]

___
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath