RFR 8169808 Stream returning methods should specify if they are late binding (original) (raw)

Doug Lea dl at cs.oswego.edu
Wed Nov 23 15:50:36 UTC 2016


On 11/23/2016 10:05 AM, Martin Buchholz wrote:

Right now, PBQ's spliterator is in violation of

"""A Spliterator that does not report IMMUTABLE or CONCURRENT is expected to have a documented policy concerning: when the spliterator binds to the element source;""" so I think we only get a choice between IMMUTABLE and CONCURRENT. I propose:

Well, OK. Hopefully no user program will hardwire which choice is made, in case the implementation changes.

-Doug

--- src/main/java/util/concurrent/PriorityBlockingQueue.java23 Nov 2016 14:51:10 -00001.116 +++ src/main/java/util/concurrent/PriorityBlockingQueue.java23 Nov 2016 15:01:29 -0000 @@ -962,3 +962,6 @@ public int characteristics() { - return Spliterator.NONNULL | Spliterator.SIZED | Spliterator.SUBSIZED; + return (Spliterator.IMMUTABLE | + Spliterator.NONNULL | + Spliterator.SIZED | + Spliterator.SUBSIZED); }

On Wed, Nov 23, 2016 at 6:14 AM, Doug Lea <dl at cs.oswego.edu_ _<mailto:dl at cs.oswego.edu>> wrote: On 11/22/2016 08:33 PM, Martin Buchholz wrote: PriorityBlockingQueue has a late-binding-style, snapshot spliterator that does not report IMMUTABLE. It is immutable ... after the first access! Should we add IMMUTABLE? Probably not. This might overly constrain future improvements; for example, someday replacing with some linked structure. Arguably, if so, we could just change the reported characteristics, but that could be surprising to users, and possibly lead to subtle user bugs. -Doug



More information about the core-libs-dev mailing list