< prev index next >

src/java.base/unix/native/libnet/Inet4AddressImpl.c

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this
--- 1,7 ---
  /*
!  * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

*** 34,13 ***
  #include <sys/time.h>
  
  #include "net_util.h"
  
  #include "java_net_Inet4AddressImpl.h"
  
  #if defined(MACOSX)
! extern jobjectArray lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6);
  #endif
  
  #define SET_NONBLOCKING(fd) {       \
      int flags = fcntl(fd, F_GETFL); \
      flags |= O_NONBLOCK;            \
--- 34,15 ---
  #include <sys/time.h>
  
  #include "net_util.h"
  
  #include "java_net_Inet4AddressImpl.h"
+ #include "java_net_spi_InetAddressResolver_LookupPolicy.h"
  
  #if defined(MACOSX)
! extern jobjectArray lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6,
+                                       int addressesOrder);
  #endif
  
  #define SET_NONBLOCKING(fd) {       \
      int flags = fcntl(fd, F_GETFL); \
      flags |= O_NONBLOCK;            \

*** 109,11 ***
      error = getaddrinfo(hostname, NULL, &hints, &res);
  
      if (error) {
  #if defined(MACOSX)
          // If getaddrinfo fails try getifaddrs, see bug 8170910.
!         ret = lookupIfLocalhost(env, hostname, JNI_FALSE);
          if (ret != NULL || (*env)->ExceptionCheck(env)) {
              goto cleanupAndReturn;
          }
  #endif
          // report error
--- 111,13 ---
      error = getaddrinfo(hostname, NULL, &hints, &res);
  
      if (error) {
  #if defined(MACOSX)
          // If getaddrinfo fails try getifaddrs, see bug 8170910.
!         // java_net_spi_InetAddressResolver_LookupPolicy_IPV4_FIRST and no ordering is ok
+         // here since only AF_INET addresses will be returned.
+         ret = lookupIfLocalhost(env, hostname, JNI_FALSE, java_net_spi_InetAddressResolver_LookupPolicy_IPV4);
          if (ret != NULL || (*env)->ExceptionCheck(env)) {
              goto cleanupAndReturn;
          }
  #endif
          // report error
< prev index next >