8235193: JDK-8235193,(dc) Remove JNI overhead from DatagramChannel.send implementation

Chris Hegarty chris.hegarty at oracle.com
Wed Dec 4 16:09:26 UTC 2019


Alan,

On 02/12/2019 18:33, Alan Bateman wrote:
> JDK-8234805 removed the JNI upcalls from DatagramChannel.receive. This 
> is a follow-up to improve the send method by eliminating the use of 
> NET_InetAddressToSockaddr (lots of JNI calls) and replacing it with code 
> to populate the socket address using the NativeSocketAddress 
> implementation class added in JDK-8234805.
> 
> The webrev with the changes is here.
>      http://cr.openjdk.java.net/~alanb/8235193/webrev/

I think that this is very good. I had the very same though ( of 
extending the use of NativeSocketAddress to send ) when I seen your 
patch that introduced it.

Inet6Address::addressBytes returns a reference to the actual byte array 
that backs the Inet6Address. The method is package-private and only 
shared through a shared-secret, so it should be fine. I don't think that 
addressBytes should clone the address, just calling it out so that we're 
all on the same page and we pay attention to keeping it safe, if there 
is future refactoring in this area.

-Chris.


More information about the nio-dev mailing list