RFR 8081678: Add Stream returning methods to classes where there currently exist only Enumeration returning methods

Paul Sandoz paul.sandoz at oracle.com
Tue Jun 2 13:37:29 UTC 2015


Hi,

Please review a follow up to Stuart's Enumeration.asIterator patch that adds some Stream return methods to classes where there is only Enumeration returning methods to support traversal:

  http://cr.openjdk.java.net/~psandoz/jdk9/JDK-8081678-enumeration-and-stream/webrev/

I took the opportunity to sprinkle some Enumerator.asIterator impls.

I originally included some methods on ClassLoader but Alan wisely warned me away from doing that as this area is likely to be impacted by modularity.

There is one small area of uncertainty with NetworkInterface. Can the following method ever return null?

 342     public static Enumeration<NetworkInterface> getNetworkInterfaces()
 343         throws SocketException {
 344         NetworkInterface[] netifs = getAll();
 345 
 346         // specified to return null if no network interfaces
 347         return netifs != null
 348                ? enumerationFromArray(netifs)
 349                : null;
 350     }

Contrary to the comment i cannot find any specification. For the stream returning method, networkInterfaces, i have specified this to return an empty stream, thus it might be good to update the enumeration returning method as well to say whether it returns null or an empty enumeration.

Paul.



More information about the core-libs-dev mailing list