RFR [8014066] Mistake in documentation of ArrayList#removeRange (original) (raw)
Doug Lea dl at cs.oswego.edu
Thu Mar 13 22:59:03 UTC 2014
- Previous message: RFR [8014066] Mistake in documentation of ArrayList#removeRange
- Next message: RFR [8014066] Mistake in documentation of ArrayList#removeRange
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 03/13/2014 12:34 PM, Martin Buchholz wrote:
I notice there are zero jtreg tests for removeRange. That should be fixed.
I notice there is a removeRange in CopyOnWriteArrayList, but it is package-private instead of "protected", which seems like an oversight. Can Doug remember any history on that?
CopyOnWriteArrayList does not extend AbstractList, but its sublist does. The sublist relies on COWAL.removeRange only for clear. So COWAL sublist clearing uses the same idea as AbstractList, and gives it the same name, but it is not the same AbstractList method, so need not be protected.
-Doug
I notice that AbstractList.removeRange contains no @throws. That should be fixed? The existing @throws javadoc from CopyOnWriteArrayList seems better: * @throws IndexOutOfBoundsException if fromIndex or toIndex out of range * ({@code fromIndex < 0 || toIndex > size() || toIndex < fromIndex})_ _This paragraph in AbstractList_ _*
This method is called by the {@code clear} operation on this list
* and its subLists. Overriding this method to take advantage of * the internals of the list implementation can substantially * improve the performance of the {@code clear} operation on this list * and its subLists. looks like it belongs inside the @implSpec (it's not a requirement on subclasses) ObTesting (a start) import java.util.*; public class RemoveRange { static class PublicArrayList extends ArrayList { PublicArrayList(int cap) { super(cap); } public void removeRange(int fromIndex, int toIndex) { super.removeRange(fromIndex, toIndex); } } public static void main(String[] args) throws Throwable { PublicArrayList x = new PublicArrayList(11); for (int i = 0; i < 11; i++) x.add(null); x.removeRange(x.size(), x.size()); } }On Thu, Mar 13, 2014 at 8:29 AM, Ivan Gerasimov <ivan.gerasimov at oracle.com_ _<mailto:ivan.gerasimov at oracle.com>> wrote: Hello! Would you please review a simple fix of the javadoc for ArrayList#removeRange() method? The doc says that IndexOutOfBoundsException is thrown if fromIndex or toIndex is out of range (fromIndex < 0 || fromIndex >= size() || toIndex > size() || toIndex < fromIndex)._ _The condition 'fromIndex >= size()' isn't true and should be removed from the doc. For example, the code list.removeRange(size(), size()) does not throw any exception. BUGURL: https://bugs.openjdk.java.net/_browse/JDK-8014066 <https://bugs.openjdk.java.net/browse/JDK-8014066> WEBREV: http://cr.openjdk.java.net/~_igerasim/8014066/0/webrev/ <http://cr.openjdk.java.net/~igerasim/8014066/0/webrev/> Sincerely yours, Ivan
- Previous message: RFR [8014066] Mistake in documentation of ArrayList#removeRange
- Next message: RFR [8014066] Mistake in documentation of ArrayList#removeRange
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]