--- old/src/java.base/unix/native/libnet/NetworkInterface.c 2019-05-16 12:42:02.982569089 +0100 +++ new/src/java.base/unix/native/libnet/NetworkInterface.c 2019-05-16 12:42:02.722569098 +0100 @@ -1071,13 +1071,21 @@ return prefix; } +static int socket0(int domain, int type, int protocol) { + if (domain == AF_INET) { + errno = EAFNOSUPPORT; + return -1; + } + return socket(domain, type, protocol); +} + /* * Opens a socket for further ioct calls. proto is one of AF_INET or AF_INET6. */ static int openSocket(JNIEnv *env, int proto) { int sock; - if ((sock = socket(proto, SOCK_DGRAM, 0)) < 0) { + if ((sock = socket0(proto, SOCK_DGRAM, 0)) < 0) { // If we lack support for this address family or protocol, // don't throw an exception. if (errno != EPROTONOSUPPORT && errno != EAFNOSUPPORT) { @@ -1100,9 +1108,9 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) { int sock; - if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + if ((sock = socket0(AF_INET, SOCK_DGRAM, 0)) < 0) { if (errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT) { - if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { + if ((sock = socket0(AF_INET6, SOCK_DGRAM, 0)) < 0) { JNU_ThrowByNameWithMessageAndLastError (env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed"); return -1;