RFR: 8079136: Accessing a nested sublist leads to StackOverflowError

Ivan Gerasimov ivan.gerasimov at oracle.com
Thu Jan 28 08:44:08 UTC 2016


Hello everyone!

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

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

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

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

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

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

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

Sincerely yours,
Ivan




More information about the core-libs-dev mailing list