InetAddress.get*() vs RFC 6724

Robert Stupp snazy at snazy.de
Fri Feb 6 10:08:17 UTC 2026


Hi all,

I wanted to test for the appetite to change the current default behavior of
the IP address lookup policy on dual-stack (IPv4+IPv6) systems.

The default evaluated in InetAddress.initializePlatformLookupPolicy()
yields 'IPV4_FIRST' to return IPv4 addresses before IPv6 addresses unless
'java.net.preferIPv6Addresses' is set to 'true'. I wonder whether this
could be changed to the system default, relying on what 'getaddrinfo'
returns?

This would make Java compliant with RFC 6724, which (strongly) recommends
to yield IPv6 addresses first.

Naively speaking, it can be confusing if something like 'curl' or 'wget'
connect via IPv6, but any Java application connects via IPv4.

Although it's a tiny code change, it would be a "big" or "surprising"
behavior change. Therefore I think, if there's appetite for such a change,
it would need to go into one of the next major releases.

WDYT?

Cheers,
Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20260206/1e24de09/attachment-0001.htm>


More information about the core-libs-dev mailing list