RFR 8169808 Stream returning methods should specify if they are late binding

Martin Buchholz martinrb at google.com
Wed Nov 23 15:05:10 UTC 2016


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:

--- src/main/java/util/concurrent/PriorityBlockingQueue.java 23 Nov 2016
14:51:10 -0000 1.116
+++ src/main/java/util/concurrent/PriorityBlockingQueue.java 23 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> 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