Same for that, as it goes together with 8167420.

From: Langer, Christoph
Sent: Mittwoch, 2. November 2016 15:37
To: 'net-dev@openjdk.java.net' <net-dev@openjdk.java.net>
Subject: RFR(M): 8167457: Switch Windows Inet4AddressImpl to 
getaddrinfo/getnameinfo

Hi,

here is the Windows counterpart of 8167420.

Bug: https://bugs.openjdk.java.net/browse/JDK-8167457
Webrev: http://cr.openjdk.java.net/~clanger/webrevs/8167457.0/

Mainly I suggest to replace gethostbyaddr/gethostbyname in Inet4AddressImpl.c 
to getaddrinfo/getnameinfo - such as Inet6AddressImpl.c on Windows is using it 
and also Inet4AddressImpl.c on Unix is already using. It goes along with a few 
other changes and pretty much aligns with the Unix counterparts of the native 
implementation. Here are the details:

Java_java_net_Inet4AddressImpl_lookupAllHostAddr:

-          use getaddrinfo instead of gethostbyname

-          no isspace(hostname[0]) check. The comment says that it is only 
needed because of a bug in Windows2000. But this version is not supported by 
OpenJDK9. And my tests show no problems with removing it.

-          no isDottedIPAddress check. This is Windows specific and I could not 
see any problems with removing it in my tests. Usually IPv4 addresses should 
not be handed down to this function, only invalid ones. And then the default 
would be to use gethostbyname.

-          use NET_ThrowByNameWithLastError after getaddrinfo non null return, 
to reflect WSAGetLastError value

Java_java_net_Inet4AddressImpl_getHostByAddr:

-          use getnameinfo instead of gethostbyaddr

Java_java_net_Inet6AddressImpl_lookupAllHostAddr:

-          use NET_ThrowByNameWithLastError after getaddrinfo non null return, 
to reflect WSAGetLastError value

Java_java_net_Inet6AddressImpl_getHostByAddr:

-          replace CHECK_NULL_RETURN(ret, NULL) with UnknownHostException in 
case of getnameinfo error - this seems more correct when looking at the usage 
of getHostByAddr in InetAddress.java

As with the other webrev for 8167420, I'll add it to our OpenJDK build/test 
environment. And I'd appreciate any feedback :)


Thanks and best regards
Christoph


Reply via email to