hg: lambda/lambda/jdk: SingletonSpliterator and more Collections default method override

David Holmes david.holmes at oracle.com
Thu Mar 21 23:28:17 PDT 2013


Hi Henry,

Your empty/singleton forEach implementations still need to check the 
action for null as per the spec for forEach

Your SingletonSpliterator factory methods are missing @param tags. And 
why use "T element" but "<primitive> value" ?

I also just noticed that Spliterator tryAdvance and forEach don't 
specify what happens if their argument is null. If they are supposed to 
throw NPE then you will need to add that to your implementations, 
otherwise this:

+ @Override
+ public boolean tryAdvance(LongConsumer consumer) {
+   if (!consumed) {
+     consumed = true;
+     consumer.accept(value);
+     return true;
+   }
+   return false;
+ }

will throw NPE _after_ setting consumed=true;

Cheers,
David

On 22/03/2013 3:38 PM, henry.jen at oracle.com wrote:
> Changeset: 3de950fdd0e7
> Author:    henryjen
> Date:      2013-03-21 22:29 -0700
> URL:       http://hg.openjdk.java.net/lambda/lambda/jdk/rev/3de950fdd0e7
>
> SingletonSpliterator and more Collections default method override
>
> ! src/share/classes/java/util/Collections.java
> ! src/share/classes/java/util/Spliterators.java
>
>


More information about the lambda-dev mailing list