Paul Krill
Editor at Large

Java internet address resolution plan proposed

news
Sep 9, 20213 mins

The OpenJDK community plans to develop a Service Provider Interface.

java -- beans, grounds, coffee -- binary background
Credit: Nathan Dumlao

Looking to enable Java applications to have finer control over internet addressing, plans are afoot in the OpenJDK community to develop a service provider interface (SPI) for host name and address resolution.

A JDK Enhancement Proposal (JEP) under consideration calls for development of such an SPI for host name resolution so <a href="https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/net/InetAddress.html" rel="nofollow">java.net.InetAddress</a> can use resolvers other than the operating platform’s built-in resolver.

In explaining the motivation for this proposal, proponents said the java.net.INetAddress API resolves host names to IP addresses and vice versa. The API currently uses the operating system’s native resolver, which typically is configured to use a combination of a local hosts file and the Domain Name System (DNS). Motivations for defining an SPI for name and address resolution include:

  • For customization, a resolver SPI would enable frameworks and applications to have finer control over resolution results and allow existing libraries to be retrofitted with a custom resolver.
  • Project Loom explores Java VM features and APIs built on them. A resolution operation within the InetAddress API currently blocks an OS call, which is a problem for Loom’s user-mode virtual threads, with platform threads unable to service other virtual threads while waiting for a resolution operation to complete. An alternative resolver could implement the DNS client protocol directly without blocking.
  • For emerging network protocols, a resolver SPI would allow seamless integration of new protocols such as DNS over Quick UDP Internet Connections (QUIC), Transport Layer Security (TLS), or HTTPS.
  • Prototyping and testing often require control of host name and address resolution results.

Oracle said the proposal was part of an effort to offer asynchronous programming in Java, because legacy DNS lookups are synchronous. The current implementation of INetAddress relies on the OS in a blocking call. The plan is to make it pluggable.

The proposal is not being targeted to any specific version of standard Java as of September 9. Without an SPI such as the one being proposed, applications will continue having to use workarounds. An application can use the Java Naming and Directory Interface (JNDI) and its DNS provider to look up network addresses and names. Although this approach can be useful for applications that require fine control of DNS lookups, it is decoupled from InetAddress, so using the platform’s networking API requires additional effort. Also, an application can use the OS’s resolver libraries directly via Java Native Interface (JNI) or the foreign function API from Project Panama. As with JNDI, this approach is decoupled from InetAddress and awkward to use.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author