On 05/01/2016 04:32, Lu, Yingqi wrote:
Hi Alan/Volker,

I just found out that the code works by adding the same static block (net 
library loading) into SocketImpl.java although isReusePortAvailable() is being 
defined in its subclass AbstractPlainSocketIml.java. I use a print statement to 
confirm that both static blocks from SocketImpl and AbstractSocketImpl are 
being executed.

Is this a reasonable way to implement? Or, we can remove the block from 
AbstractPlainSocketImpl, only have it in SocketImpl if you think that is 
better. Please let us know.

I'm not sure that I understand the issue you are seeing.

When a Socket is created then it will invoke setImpl to set the underlying SocketImpl and that should cause the configured SocketImpl to be loaded and initialize. Are you saying that the initializer isn't run?

BTW: The reason for putting this into the concrete implementation of SocketImpl is that the Socket API is somewhat pluggable via the legacy (and probably rarely used) SocketImplFactory mechanism. This means that some SocketImpl implementations might know about the new socket options, some might not.

-Alan

Reply via email to