Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8344351

Adjust specifications of java.net.NetworkInterface methods getInetAddresses, inetAddresses and getInterfaceAddresses post JEP-486

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 24
    • core-libs
    • minimal
    • This change updates the documentation to be in line with actual behavior post JEP-486. No behavior changes are introduced.
    • Java API
    • SE

      Summary

      Adjust the specification of the java.net.NetworkInterface methods getInetAddresses, inetAddresses and getInterfaceAddresses to reflect changes post JEP-468

      Problem

      These methods in NetworkInterface has historically filtered their results to remove entries which does not pass the SecurityManager::checkConnect method. JEP-486 removed any references to SecurityManager for these methods, but left out updating the "with all, or a subset of" part of the method descriptions.

      Since there is no SecurityManager filtering anymore, these methods should simply say what they return.

      Solution

      • Remove "with all, or a subset.." from NetworkInterface.getInetAddresses, NetworkInterface.inetAddresses and NetworkInterface.getInterfaceAddresses method descriptions
      • Update the '@return' text for these methods accordingly

      Specification

      Here's a patch for the Javadoc changes:

      diff --git a/src/java.base/share/classes/java/net/NetworkInterface.java b/src/java.base/share/classes/java/net/NetworkInterface.java
      index 1c5edd1c23f..0a8f66827f3 100644
      --- a/src/java.base/share/classes/java/net/NetworkInterface.java
      +++ b/src/java.base/share/classes/java/net/NetworkInterface.java
      @@ -118,16 +118,15 @@ public String getName() {
           }
      
           /**
      -     * Get an Enumeration with all, or a subset, of the InetAddresses bound to
      -     * this network interface.
      +     * Get an Enumeration of the InetAddresses bound to this network interface.
            *
            * @implNote
      -     * The returned enumeration contains all, or a subset, of the InetAddresses that were
      -     * bound to the interface at the time the {@linkplain #getNetworkInterfaces()
      +     * The returned enumeration contains the InetAddresses that were bound to
      +     * the interface at the time the {@linkplain #getNetworkInterfaces()
            * interface configuration was read}
            *
      -     * @return an Enumeration object with all, or a subset, of the InetAddresses
      -     * bound to this network interface
      +     * @return an Enumeration object with the InetAddresses bound to this
      +     * network interface
            * @see #inetAddresses()
            */
           public Enumeration<InetAddress> getInetAddresses() {
      @@ -135,16 +134,14 @@ public String getName() {
           }
      
           /**
      -     * Get a Stream of all, or a subset, of the InetAddresses bound to this
      -     * network interface.
      +     * Get a Stream of the InetAddresses bound to this network interface.
            *
            * @implNote
      -     * The stream contains all, or a subset, of the InetAddresses that were
      -     * bound to the interface at the time the {@linkplain #getNetworkInterfaces()
      +     * The stream contains the InetAddresses that were bound to the
      +     * interface at the time the {@linkplain #getNetworkInterfaces()
            * interface configuration was read}
            *
      -     * @return a Stream object with all, or a subset, of the InetAddresses
      -     * bound to this network interface
      +     * @return a Stream object with the InetAddresses bound to this network interface
            * @since 9
            */
           public Stream<InetAddress> inetAddresses() {
      @@ -177,11 +174,11 @@ public String getName() {
           }
      
           /**
      -     * Get a List of all, or a subset, of the {@code InterfaceAddresses}
      -     * of this network interface.
      +     * Get a List of the {@code InterfaceAddresses} of this network interface.
      +     *
      +     * @return a {@code List} object with the InterfaceAddress of this
      +     * network interface
            *
      -     * @return a {@code List} object with all, or a subset, of the
      -     *         InterfaceAddress of this network interface
            * @since 1.6
            */
           public java.util.List<InterfaceAddress> getInterfaceAddresses() {

            eirbjo Eirik Bjørsnøs
            dfuchs Daniel Fuchs
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: