Hi Robert,
Robert Schuster schrieb:
Hi Roman,
could you please add a comment to these methods that says that the NPEs are
supposed to be thrown implicitly. Otherwise I find it a bit odd that the javadoc
mentions the exceptions explicitly.
Sure.
2006-08-15 Roman Kennke <[EMAIL PROTECTED]>
* java/util/Vector.java
(removeAll): Added comment about NPE.
(retainAll): Added comment about NPE.
/Roman
Index: java/util/Vector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Vector.java,v
retrieving revision 1.28
diff -u -1 -2 -r1.28 Vector.java
--- java/util/Vector.java 15 Aug 2006 09:44:33 -0000 1.28
+++ java/util/Vector.java 15 Aug 2006 14:28:32 -0000
@@ -711,24 +711,29 @@
}
/**
* Remove from this vector all elements contained in the given collection.
*
* @param c the collection to filter out
* @return true if this vector changed
* @throws NullPointerException if c is null
* @since 1.2
*/
public synchronized boolean removeAll(Collection c)
{
+ // The NullPointerException is thrown implicitly when the Vector
+ // is not empty and c is null. The RI allows null arguments when
+ // the vector is empty. See Mauve test:
+ // gnu/testlet/java/util/Vector/removeAll.java
+
int i;
int j;
for (i = 0; i < elementCount; i++)
if (c.contains(elementData[i]))
break;
if (i == elementCount)
return false;
modCount++;
for (j = i++; i < elementCount; i++)
if (! c.contains(elementData[i]))
elementData[j++] = elementData[i];
@@ -737,24 +742,29 @@
}
/**
* Retain in this vector only the elements contained in the given collection.
*
* @param c the collection to filter by
* @return true if this vector changed
* @throws NullPointerException if c is null
* @since 1.2
*/
public synchronized boolean retainAll(Collection c)
{
+ // The NullPointerException is thrown implicitly when the Vector
+ // is not empty and c is null. The RI allows null arguments when
+ // the vector is empty. See Mauve test:
+ // gnu/testlet/java/util/Vector/retainAll.java
+
int i;
int j;
for (i = 0; i < elementCount; i++)
if (! c.contains(elementData[i]))
break;
if (i == elementCount)
return false;
modCount++;
for (j = i++; i < elementCount; i++)
if (c.contains(elementData[i]))
elementData[j++] = elementData[i];