hg: lambda/lambda/jdk: Streams cleanups; add optimized forEach implementations; include subList in tested lists
Remi Forax
forax at univ-mlv.fr
Mon Nov 19 02:51:11 PST 2012
On 11/19/2012 10:47 AM, Paul Sandoz wrote:
> On Nov 18, 2012, at 9:28 PM, Brian Goetz <brian.goetz at Oracle.COM> wrote:
>
>>> A code like this should throw a CME and not an AIOOBE
>>> arraylist.forEach(e -> { arraylist.remove(e); })
>> The current code won't do that, as it copies the array into a local var
>> before the loop, so the indexes are always valid.
>>
>> A reasonable middle ground is a comodification check after the loop
>> terminates.
>>
> Yes, that's what Mike did with the original array proxy stuff.
>
> It's not a fail-fast solution thus risks "arbitrary, non-deterministic behavior at an undetermined time in the future", but i think it is within the scope of ConcurrentModificationException.
The question is why ArrayList.forEach should not be fail-fast ?
java.util collection iterators are fail-fast, I think that forEach on
such collections should be fail-fast too,
just to have a clean defined semantics.
>
> Paul.
>
>
Rémi
More information about the lambda-dev
mailing list