Module exports for java.base: NIO stuff

Alan Bateman Alan.Bateman at oracle.com
Sun Dec 11 11:18:26 UTC 2016


On 10/12/2016 15:21, David M. Lloyd wrote:

> Would it be possible to have all available selector provider 
> implementation classes listed in a "provides java.nio.channels.spi 
> with ..." section of java.base's module descriptor?  My use case is as 
> follows:
>
> Our I/O library (XNIO) relies on the ability to detect and use 
> different available selector providers for different purposes in 
> different circumstances (often to provide alternatives in the event of 
> platform-specific behavior problems, or to prefer lighter providers 
> over heavier ones in certain situations).  Right now we directly use 
> reflection to seek out specific named classes. However, it would be 
> much better if we could instead use a service loader to discover all 
> available implementations, which would free us from having to use 
> reflection for this purpose and also avoid lots of pointless probing.
>
> Today you need to have --add-exports=java.base/sun.nio.ch=xxx which is 
> definitely not ideal.
>
> Maybe there's another solution to this problem as well; suggestions 
> welcome.
>
I don't think we've ever come across alternative implementations of 
SelectorProvider, are these complete implementations? Are you attempting 
to wrap the default implementation - I ask because there isn't anything 
in the service type (SelectorProvider in this example) that is useful 
for doing selection.

-Alan.



More information about the jigsaw-dev mailing list