RFR: 8005051: default methods for Iterator

Akhil Arora akhil.arora at oracle.com
Thu Dec 13 17:24:35 PST 2012


As part of the library lambdafication, this patch adds a forEach default 
method to Iterator, and converts remove() into a default method so that 
implementations of Iterator no longer have to override remove if they 
desire the default behavior, which is to throw an 
UnsupportedOperationException.

http://cr.openjdk.java.net/~akhil/8005051.0/webrev/

The above patch requires a small patch to an internal class which 
happens to implement both Iterable and Iterator. Now both Iterable and 
Iterator supply a default forEach method, so the compiler balks. One 
minimally intrusive solution is for this class to override both defaults 
and provide its own version of forEach.

http://cr.openjdk.java.net/~akhil/8005053.0/webrev/

Please review
Thanks


More information about the lambda-dev mailing list