JDK-8279329 : Remove hardcoded IPv4 available policy on Windows
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • CPU: x86_64
  • Submitted: 2021-12-29
  • Updated: 2022-02-21
  • Resolved: 2022-02-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19
19 b09Fixed
Related Reports
Relates :  
Relates :  
Description
InetAddress::initializePlatformLookupPolicy() invokes 
isIPv4Available()

this will retrieve a state variable indicating the availability of IPv4. On Windows OS platforms this is hardcoded to true as determined by native function IPv4_supported in 

open/src/java.base/windows/native/libnet/net_util_md.c

jint  IPv4_supported()
{
    /* TODO: properly check for IPv4 support on Windows */
    return JNI_TRUE;
}


This has implications on IPv6 only platforms, and as such skews the lookup policy on such platforms

It would seem appropriate to amend this function to test the socket creation as per other OS platforms

jint  IPv4_supported()
{
    SOCKET s = socket(AF_INET, SOCK_STREAM, 0) ;
    if (s == INVALID_SOCKET) {
        return JNI_FALSE;
    }
    closesocket(s);

    return JNI_TRUE;
    /* TODO: properly check for IPv4 support on Windows */
   // return JNI_TRUE;
}

Comments
Changeset: f2a9627c Author: Masanori Yano <myano@openjdk.org> Committer: Alan Bateman <alanb@openjdk.org> Date: 2022-02-08 08:31:10 +0000 URL: https://git.openjdk.java.net/jdk/commit/f2a9627c05f9ef82eb83d8c1b9d4209bf42e7d8d
08-02-2022

This change is needed for InetAddress to function properly in a Windows IPv6 only environment and indirectly JDK-8279566 has a dependency on it. This was found when executing some sanity checks in IPv6 only configuration e.g. InetAddress.getLoopbackAddress always returns 127.0.0.1 rather than 0::1
04-02-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7317 Date: 2022-02-02 08:31:08 +0000
02-02-2022