# HG changeset patch # User clanger # Date 1479383105 -3600 # Thu Nov 17 12:45:05 2016 +0100 # Node ID e239a6bc95dc4924e25e5bccb706fee8e92435a8 # Parent 3029254067a96a1e932446ac00750c27894bcb93 8169865: Downport minor fixes in java.net native code from JDK 9 to JDK 8 diff --git a/src/solaris/native/java/net/Inet6AddressImpl.c b/src/solaris/native/java/net/Inet6AddressImpl.c --- a/src/solaris/native/java/net/Inet6AddressImpl.c +++ b/src/solaris/native/java/net/Inet6AddressImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, 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 @@ -75,18 +75,14 @@ } else { // ensure null-terminated hostname[NI_MAXHOST] = '\0'; -#if defined(__linux__) || defined(_ALLBSD_SOURCE) - /* On Linux/FreeBSD gethostname() says "host.domain.sun.com". On - * Solaris gethostname() says "host", so extra work is needed. - */ -#else + /* Solaris doesn't want to give us a fully qualified domain name. * We do a reverse lookup to try and get one. This works * if DNS occurs before NIS in /etc/resolv.conf, but fails * if NIS comes first (it still gets only a partial name). * We use thread-safe system calls. */ -#ifdef AF_INET6 +#if defined(__solaris__) && defined(AF_INET6) struct addrinfo hints, *res; int error; @@ -111,8 +107,7 @@ freeaddrinfo(res); } -#endif /* AF_INET6 */ -#endif /* __linux__ || _ALLBSD_SOURCE */ +#endif } return (*env)->NewStringUTF(env, hostname); } diff --git a/src/solaris/native/java/net/net_util_md.c b/src/solaris/native/java/net/net_util_md.c --- a/src/solaris/native/java/net/net_util_md.c +++ b/src/solaris/native/java/net/net_util_md.c @@ -333,6 +333,7 @@ if (getsockname(0, (struct sockaddr *)&sa, &sa_len) == 0) { struct sockaddr *saP = (struct sockaddr *)&sa; if (saP->sa_family != AF_INET6) { + close(fd); return JNI_FALSE; } } @@ -1207,16 +1208,10 @@ int *len) { int rv; + socklen_t socklen = *len; -#ifdef __solaris__ - rv = getsockopt(fd, level, opt, result, len); -#else - { - socklen_t socklen = *len; - rv = getsockopt(fd, level, opt, result, &socklen); - *len = socklen; - } -#endif + rv = getsockopt(fd, level, opt, result, &socklen); + *len = socklen; if (rv < 0) { return rv;