Hi Ivan,

Have you considered to simply override/change subList(int fromIndex, int toIndex) in SubList and RandomAccessSubList - so that 'l'/'parent' points always to the original
root list (instead of being a sublist of sublist of sublist)?

It seems to me that overriding sublist to create a sublist based on
'l'/'parent' instead of basing it on 'this' would solve the same problem
 with much less modifications... Or am I maybe missing something?

best regards,

-- daniel

On 5/5/15 9:17 AM, Ivan Gerasimov wrote:
Hello!

When creating a sublist with List.subList(), it keeps a reference to its parent. Then, when accessing (get(), set(), add(), remove(), etc.) the sublist, it recursively calls the corresponding methods of its parent.
This recursion, when deep enough, can cause StackOverflowError.

The only reason to do things recursively here, is the need to update modCount and size of all the parents.
So, the proposal is to update these fields in a loop.

A few cleanups were done along the way.

Would you please help review the fix?

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

Sincerely yours,
Ivan

Reply via email to