RFR: 8005051: default methods for Iterator

Akhil Arora akhil.arora at oracle.com
Fri Dec 14 01:24:35 UTC 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 


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.


Please review

More information about the core-libs-dev mailing list