Module exports for java.base: NIO stuff

David M. Lloyd david.lloyd at redhat.com
Sat Dec 10 15:21:26 UTC 2016


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.

-- 
- DML


More information about the jigsaw-dev mailing list