RFR: 8005051: default methods for Iterator (original) (raw)
Chris Hegarty chris.hegarty at oracle.com
Fri Dec 14 11:46:57 UTC 2012
- Previous message: RFR: 8005051: default methods for Iterator
- Next message: RFR: 8005051: default methods for Iterator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 14/12/2012 01:24, Akhil Arora wrote:
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.
This is not specified. Different Java SE implementations can have different default implementations of remove(). Your statement is either mistaken, or the changes will not meet their original intent.
forEach, it is not clear to me if the method description is specifying what the default implementation is supposed to do, or if it is specifying the contract for the method.
This, of course, has the same underlying cause as what is being discussed in other mail threads. I would like to see a clear decision being made around how default methods are to be specified before we start moving them into jdk8.
-Chris.
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
- Previous message: RFR: 8005051: default methods for Iterator
- Next message: RFR: 8005051: default methods for Iterator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]