Non interference enforcement

Remi Forax forax at
Wed Sep 26 07:16:47 PDT 2012

On 09/26/2012 03:37 PM, Brian Goetz wrote:
> Right.
> The existing enforcment uses a nonvolatile count; if we were to check 
> it during a forEach (the other option), it would likely be hoisted out 
> of the loop anyway.

non-volatile -> not an issue, java.util collection aren't concurrent.

Let's restrict ourselves to the case where the forEach loop and the 
collection mutation appear in the same thread.
The count check is done in the forEach and the mutator increments the 
count so value can be hoisted.


> On 9/26/2012 9:35 AM, Remi Forax wrote:
>> On 09/26/2012 03:28 PM, Brian Goetz wrote:
>>> We do piggyback on some degree of fail-fast when we use their 
>>> iterators.
>> yes, but using an iterator is not mandatory, right ?
>> Rémi
>>> On 9/26/2012 9:26 AM, Remi Forax wrote:
>>>> We currently ask users to write lambdas that doesn't interfere with 
>>>> the
>>>> source collection
>>>> of a stream but it's not enforced in the code.
>>>> By example,
>>>> -> { list.remove(e); });
>>>> may works or not depending how the pipeline is implemented.
>>>> This is a serous departure for the current way java.util collections
>>>> works
>>>> and I wonder if we should not keep the fail-fast guarantee for those
>>>> collections.
>>>> Rémi

More information about the lambda-libs-spec-observers mailing list