harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r400041 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/AbstractList.java test/java/tests/api/java/util/AbstractListTest.java
Date Fri, 05 May 2006 10:49:39 GMT
Author: mloenko
Date: Fri May  5 03:49:35 2006
New Revision: 400041

URL: http://svn.apache.org/viewcvs?rev=400041&view=rev
Log:
fixes for HARMONY-389
AbstractList subList bounds checking is wrong

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java?rev=400041&r1=400040&r2=400041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
Fri May  5 03:49:35 2006
@@ -256,7 +256,7 @@
 
 		public Object get(int location) {
 			if (modCount == fullList.modCount) {
-				if (0 <= location && location <= size)
+				if (0 <= location && location < size)
 					return fullList.get(location + offset);
 				throw new IndexOutOfBoundsException();
 			}
@@ -280,7 +280,7 @@
 
 		public Object remove(int location) {
 			if (modCount == fullList.modCount) {
-				if (0 <= location && location <= size) {
+				if (0 <= location && location < size) {
 					Object result = fullList.remove(location + offset);
 					size--;
 					modCount = fullList.modCount;
@@ -304,7 +304,7 @@
 
 		public Object set(int location, Object object) {
 			if (modCount == fullList.modCount) {
-				if (0 <= location && location <= size)
+				if (0 <= location && location < size)
 					return fullList.set(location + offset, object);
 				throw new IndexOutOfBoundsException();
 			}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java?rev=400041&r1=400040&r2=400041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java
Fri May  5 03:49:35 2006
@@ -161,13 +161,38 @@
 				"Sublist returned should not have implemented Random Access interface",
 				!(ll.subList(3, 7) instanceof RandomAccess));
 
-	}
+        }
 
-	protected void setUp() {
-	}
+	/**
+     * @tests java.util.AbstractList#subList(int, int)
+     */
+    public void test_subList_empty() {
+        // Regression for HARMONY-389
+        List al = new ArrayList();
+        al.add("one");
+        List emptySubList = al.subList(0, 0);
 
-	protected void tearDown() {
-	}
+        try {
+            emptySubList.get(0);
+            fail("emptySubList.get(0) should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+
+        try {
+            emptySubList.set(0, "one");
+            fail("emptySubList.set(0,Object) should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+
+        try {
+            emptySubList.remove(0);
+            fail("emptySubList.remove(0) should throw IndexOutOfBoundsException");
+        } catch (IndexOutOfBoundsException e) {
+            // expected
+        }
+    }
 
 	protected void doneSuite() {
 	}



Mime
View raw message