RFR: 8079136: Accessing a nested sublist leads to StackOverflowError
Martin Buchholz
martinrb at google.com
Wed May 6 23:23:43 UTC 2015
Hi Ivan,
I'm afraid of these changes - they are hard to review.
Can't we fix the SOE with a relatively small change to ArrayList.SubList
methods that recursively invoke parent methods to use iteration instead,
i.e. can't you implement updateSizeAndModCount in the existing SubList
class?
---
I would make modCount an argument to updateSizeAndModCount.
---
Separate out hot and cold code in subListRangeCheck (although pre-existing
code had the same problem)
+ static void subListRangeCheck(int fromIndex, int toIndex, int size) {
+ if (fromIndex < 0)
+ throw new IndexOutOfBoundsException("fromIndex = " +
fromIndex);
+ if (toIndex > size)
+ throw new IndexOutOfBoundsException("toIndex = " + toIndex);
+ if (fromIndex > toIndex)
+ throw new IllegalArgumentException("fromIndex(" + fromIndex +
+ ") > toIndex(" + toIndex +
")");
+ }
+
if ((fromIndex < 0) | (toIndex > size) | (fromIndex > toIndex)) slowpath();
---
java style consensus has been converging on: java source files should have
exactly one top-level class. It seems like you changed inner class SubList
to be a top-level class - why?
+class ArraySubList<E> extends AbstractList<E> implements RandomAccess {
On Wed, May 6, 2015 at 1:25 PM, Ivan Gerasimov <ivan.gerasimov at oracle.com>
wrote:
> And here's another update:
>
> WEBREV: http://cr.openjdk.java.net/~igerasim/8079136/2/webrev/
>
More information about the core-libs-dev
mailing list