Re: [Bug 282251] java/openjdk22: IPv6 / INET6 is broken

From: Harald Eilertsen <haraldei_at_anduin.net>
Date: Tue, 07 Jul 2026 09:15:27 UTC
On Mon, Jul 06, 2026 at 09:45:32PM +0000, bugzilla-noreply@freebsd.org wrote:
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282251
>
> --- Comment #11 from Patrick Mackinlay <freebsd.68fba@nospam.spacesurfer.com> ---
> On openjdk25 (current stable java), the code at the top works whatever the
> net.inet6.ip6.v6only sysctl is set to.
> But, with -Djava.net.preferIPv4Stack=true the code fails with "Failed to
> connect to localhost with INET6"

That is the expected behaviour.

> I think it should work regardless of what you set the value to, it does in
> linux.

That's strange. I get identical results in both ArchLinux with OpenJDK
26 and on FreeBSD with OpenJDK 25, 26 and mainline. All of them
correctly refuses to bind to an IPv6 address if preferIPv4Stack is set.

From the network bootup code in the JVM, this is clearly as intended
even though I agree the naming of the option makes it unclear that it
actually disables IPv6 support completely.

https://github.com/battleblow/jdk/blob/bsd-port/src/java.base/share/native/libnet/net_util.c#L84

Take care!
Harald