JDK-8339414 : Fix JDK-8202369 incorrect backport for 8u
  • Type: Task
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8u192
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-09-03
  • Updated: 2025-06-16
  • Resolved: 2025-06-16
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.
Other
openjdk8u472 masterFixed
Related Reports
Relates :  
Description
JDK-8202369 backport does not modify the Java_java_net_Inet4AddressImpl_getLocalHostName method of non-BSD systems.

```
/************************************************************************
 * Inet4AddressImpl
 */

/*
 * Class:     java_net_Inet4AddressImpl
 * Method:    getLocalHostName
 * Signature: ()Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL
Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
    char hostname[NI_MAXHOST+1];

    hostname[0] = '\0';
    if (JVM_GetHostName(hostname, sizeof(hostname))) {
        /* Something went wrong, maybe networking is not setup? */
        strcpy(hostname, "localhost");
    } else {
        struct addrinfo hints, *res;
        int error;

        hostname[NI_MAXHOST] = '\0';
        memset(&hints, 0, sizeof(hints));
        hints.ai_flags = AI_CANONNAME;
        hints.ai_family = AF_INET;

        error = getaddrinfo(hostname, NULL, &hints, &res);

        if (error == 0) {/* host is known to name service */
            getnameinfo(res->ai_addr,
                        res->ai_addrlen,
                        hostname,
                        NI_MAXHOST,
                        NULL,
                        0,
                        NI_NAMEREQD);

            /* if getnameinfo fails hostname is still the value
               from gethostname */

            freeaddrinfo(res);
        }
    }
    return (*env)->NewStringUTF(env, hostname);
}
```
Comments
Changeset: 51b63079 Branch: master Author: Thomas Fitzsimmons <fitzsim@redhat.com> Committer: Andrew John Hughes <andrew@openjdk.org> Date: 2025-06-16 23:04:07 +0000 URL: https://git.openjdk.org/jdk8u-dev/commit/51b6307937d9584f8690e4916444e479eeafff28
16-06-2025

[jdk8u-fix-request] Approval Request from Thomas Fitzsimmons This fix is ready.
06-06-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk8u-dev/pull/661 Date: 2025-06-04 20:44:19 +0000
05-06-2025

[~fitzsim] You can assign it to your self and work on the upstream fix
04-06-2025