Index: modules/luni/src/main/java/java/util/AbstractList.java =================================================================== --- modules/luni/src/main/java/java/util/AbstractList.java.orig 2006-04-21 15:21:54.000000000 +0100 +++ modules/luni/src/main/java/java/util/AbstractList.java 2006-04-21 15:39:56.000000000 +0100 @@ -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(); } Index: modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java =================================================================== --- modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java.orig 2006-03-29 10:29:02.000000000 +0100 +++ modules/luni/src/test/java/tests/api/java/util/AbstractListTest.java 2006-04-21 17:35:05.000000000 +0100 @@ -161,6 +161,34 @@ "Sublist returned should not have implemented Random Access interface", !(ll.subList(3, 7) instanceof RandomAccess)); + } + + /** + * @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); + 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 setUp() {