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

Description of getByName method should be clarified

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 6
    • core-libs
    • None
    • x86
    • linux

      Specification for InetAddress.getByName() looks as followns:

      -------------------------------
      public static InetAddress getByName(String host)
                                   throws UnknownHostException

          Determines the IP address of a host, given the host's name.

          The host name can either be a machine name, such as "java.sun.com", or a textual representation of its IP address. If a literal IP address is supplied, only the validity of the address format is checked.

          For host specified in literal IPv6 address, either the form defined in RFC 2732 or the literal IPv6 address format defined in RFC 2373 is accepted. IPv6 scoped addresses are also supported. See here for a description of IPv6 scoped addresses.

          If the host is null then an InetAddress representing an address of the loopback interface is returned. See RFC 3330 section 2 and RFC 2373 section 2.5.3.

          Parameters:
              host - the specified host, or null.
          Returns:
              an IP address for the given host name.
          Throws:
              UnknownHostException - if no IP address for the host could be found, or if a scope_id was specified for a global IPv6 address.
              SecurityException - if a security manager exists and its checkConnect method doesn't allow the operation
      -------------------------------

      So there are 2 possible modes for this method:

      * resolving address for symbolic name
      * just factory method converting string representation of IP address into InetAddress instance

      Check for security permission is reeasonable jsut for first mode and JDK behaves in such manner. However, it is not clear from method specification that checkConnect should not be invoked for second mode.

      This issue is applied to getAllByName() too.

            chegar Chris Hegarty
            sreznick Sergey Reznick (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: