This fixes the "hashCode" method to comply with the OpenJDK
documentation. Now we pass all the public domain tck tests for this
class, except the SubList one.

Thanks,
Mario

2008-03-26  Mario Torre  <[EMAIL PROTECTED]>

        * java/util/concurrent/CopyOnWriteArrayList.java (equals):
        removed useless local variable.
        (hashCode): new method.
-- 
Mario Torre, Software Developer, http://www.jroller.com/neugens/
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-53
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

USt-Id: DE216375633, Handelsregister HRB 109481, AG Mannheim
Geschäftsführer: Dr. James J. Hunt

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
### Eclipse Workspace Patch 1.0
#P classpath
Index: java/util/concurrent/CopyOnWriteArrayList.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/concurrent/CopyOnWriteArrayList.java,v
retrieving revision 1.7
diff -u -r1.7 CopyOnWriteArrayList.java
--- java/util/concurrent/CopyOnWriteArrayList.java	25 Mar 2008 19:56:29 -0000	1.7
+++ java/util/concurrent/CopyOnWriteArrayList.java	26 Mar 2008 11:18:33 -0000
@@ -705,8 +705,6 @@
     if (this == o)
       return true;
     
-    boolean _equals = false;
-    
     // let's see if 'o' is a list, if so, we need to compare the elements
     // as returned by the iterator
     if (o instanceof List)
@@ -723,10 +721,21 @@
               return false;
           }
 
-        _equals = true;
+        return true;
+      }
+    
+    return false;
+  }
+  
+  public int hashCode()
+  {
+    // see http://java.sun.com/6/docs/api/java/util/List.html#hashcode()
+    int hashcode = 1;
+    for (E element : this)
+      {
+        hashcode = 31 * hashcode + (element == null ? 0 : element.hashCode());
       }
-     
-    return _equals;
+    return hashcode;
   }
   
   /**
Index: ChangeLog
===================================================================
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.9566
diff -u -r1.9566 ChangeLog
--- ChangeLog	25 Mar 2008 19:56:30 -0000	1.9566
+++ ChangeLog	26 Mar 2008 11:18:33 -0000
@@ -1,3 +1,9 @@
+2008-03-26  Mario Torre  <[EMAIL PROTECTED]>
+
+	* java/util/concurrent/CopyOnWriteArrayList.java (equals): removed useless
+	local variable. 
+	(hashCode): new method.
+
 2008-03-25  Mario Torre  <[EMAIL PROTECTED]>
 
 	* java/util/concurrent/CopyOnWriteArrayList.java (clone): clone method

Reply via email to