RFR: 8079136: Accessing a nested sublist leads to StackOverflowError

Tagir F. Valeev amaembo at gmail.com
Fri Jan 29 04:16:08 UTC 2016


AbstractList::subListRangeCheck could be replaced with new
Objects::checkFromToIndex for consistency with other methods. Also
AbstractList::rangeCheck could be replaced with Obejcts::checkIndex.
The same for ArrayList class.

Otherwise looks good to me.

With best regards,
Tagir Valeev.

IG> Hello everyone!

IG> I'd like to respin the discussion.
IG> The previous attempt can be found here:
IG> http://mail.openjdk.java.net/pipermail/core-libs-dev/2015-May/033159.html

IG> BUGURL: https://bugs.openjdk.java.net/browse/JDK-8079136
IG> WEBREV: http://cr.openjdk.java.net/~igerasim/8079136/05/webrev/

IG> Here's the summary of the proposed changes:
IG> 1)
IG> Sublist of an AbstractList (AbstractList.SubList class) now maintains a
IG> link to the root AbstractList, and not only to the immediate parent list.
IG> This allows to perform modifications on the chain of sub-lists in a loop
IG> instead of using recursion (which, in particular, helps avoid the 
IG> stack-overflow problem).
IG> The sublist is still backed by its parent list, in sense that all the 
IG> modifications are correctly reflected in the backing list (as well as in
IG> all the grand parents the sublist, if any), so the fix does not violate
IG> the existing specification.

IG> 2)
IG> It is proposed to update the spec of AbstractList.subList() in the 
IG> @implSpec section by removing the words about private fields.
IG> With the fix, some of those private fields are removed.

IG> 3)
IG> A similar change is proposed for the ArrayList.SubList class.

IG> 4)
IG> Two regression tests are added:
IG> NestedSubList.java - demonstrates a stack-overflow problem when dealing
IG> with a long chain of sublists,
IG> SubList.java - tests basic functionality of sub-lists, which helps us 
IG> make sure nothing is broken with the proposed change.

IG> If people agree that the fix is good, I'll file a CCC request for 
IG> changing the spec of AbstractList.subList().

IG> Sincerely yours,
IG> Ivan

More information about the core-libs-dev mailing list