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

Implementation of JEP 418: Internet-Address Resolution SPI

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P3
    • Resolution: Approved
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Risk:
      low
    • Compatibility Risk Description:
      Hide
      A new SPI and a mechanism to locate and install custom resolver implementations are introduced.
      No alternative resolver implementation is added to the JDK.
      There should be no observable behavorior change in the regular case.
      The built-in resolver that delegates to O/S resolver will continue to be used by default.

      The non-standard, JDK-specific system property "jdk.net.hosts.file" that can be specified to use a specific hosts file will continue to take precedence over the built-in resolver or a custom resolver if one is available.
      Show
      A new SPI and a mechanism to locate and install custom resolver implementations are introduced. No alternative resolver implementation is added to the JDK. There should be no observable behavorior change in the regular case. The built-in resolver that delegates to O/S resolver will continue to be used by default. The non-standard, JDK-specific system property "jdk.net.hosts.file" that can be specified to use a specific hosts file will continue to take precedence over the built-in resolver or a custom resolver if one is available.
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Add new Service Provider Interface (SPI) to allow customization of InetAddress API methods implementing host name and address resolution requests.

      Problem

      InetAddress API methods delegate to built-in resolver to perform an Internet-Address (IP) resolution operations. The built-in resolver is responsible for forwarding the resolution requests to Operating System (O/S) resolver. Currently, there is no mechanism available to replace it with a custom resolver implementation. The built-in resolver is problematic for Virtual Threads (project Loom) as it will block in the kernel, which limits the number of concurrent requests that can be sent in parallel. Providing an SPI would allow applications that need massive parallelism to replace the built-in implementation with a more scalable implementation.

      Solution

      Introduce a new Java standard service provider interface that allows installing a custom resolver implementation as the built-in resolver replacement. More information is available in JEP-418

      Specification

      The list of InetAddress API methods that will use a custom resolver, if one installed:

      • IP address (forward) lookup methods: InetAddress.getAllByName and InetAddress.getByName
      • Host name (reverse) lookup methods: InetAddress.getCanonicalHostName and InetAddress.getHostName

      Summary of new SPI classes added to 'java.net.spi' package:

      • InetAddressResolverProvider - a new abstract class defining a service provider, and is, essentially, a factory for InetAddressResolver resolvers.
      • InetAddressResolverProvider.Configuration - a new sealed interface describing the platform's built-in configuration for resolution operations.
      • InetAddressResolver - an interface that defines methods for the forward and reverse lookup operations.
      • InetAddressResolver.LookupPolicy - a final class whose instances describe the characteristics of a forward lookup operation.

      List of API documentation changes that can be found in attached specdiff.zip archive:

      • Document new SPI classes added to java.net.spi package.
      • Changes to java.net.InetAddress: Extend class-level documentation to describe how new SPI works; update javadocs for existing API methods to use resolver term.
      • Add new inetAddressResolverProvider permission to a table with the standard target names in RuntimePermission class-level javadoc

      Attached webrev.zip also contains a change to src/java.base/share/classes/java/net/doc-files/net-properties.html file as well as to the src/java.base/share/classes/module-info.java file alongside to other implementation changes. (changes to these two files are unfortunately not tracked by the specdiff)

        Attachments

        1. specdiff.zip
          756 kB
        2. specdiff-1.zip
          784 kB
        3. specdiff-2.zip
          784 kB
        4. specdiff-3.zip
          784 kB
        5. specdiff-4.zip
          784 kB
        6. webrev.zip
          796 kB
        7. webrev-1.zip
          810 kB
        8. webrev-2.zip
          829 kB
        9. webrev-3.zip
          832 kB
        10. webrev-4.zip
          832 kB

          Issue Links

            Activity

              People

              Assignee:
              aefimov Aleksej Efimov
              Reporter:
              aefimov Aleksej Efimov
              Reviewed By:
              Alan Bateman, Daniel Fuchs
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: