On 7 March 2018 at 12:59, Alan Bateman <alan.bate...@oracle.com> wrote: > You've dismissed services but I would expect it to provide a nice solution. > The service interface might be very simple, something like: > > public interface LeapSecondDataProvider { > LeapSecondData data(); > }
Configuration and code are two very different things. Asking projects and end users to write code for something that should be config is a huge no-no. My view is that JPMS has made using configuration files, especially for libraries, a lot harder. This is a step back in usability. Just so we are clear, for leap seconds I will now have to ask users to manually register them using an API where previously they just added a file. But for OpenGamma Strata, the configuration files are much more complex and certainly unsuited to be code, even if the backwards compatibility issues were acceptable. (This is a pattern I've used for configuration for many years) Effectively what is needed is another way for a library to be informed of the presence of the calling application. One possible solution to this would be to allow users to write module initialization code in module-info.java. Then an application coder would have a solid reliable place to put code that registers the additional configuration files with the low-level library. Something like: module com.foo.app { requires org.threeten.extra; init(ModuleInitContext context) { UtcRules.registerLeapSecondFile("/com/foo/app/LeapSeconds.txt"); } } PS. ServiceLoader is a pain to use in Java 9 too. As a library doesn't know whether it will run as a named module or on the classpath, I have to duplicate the service loader configuration - once in META-INF/services and once in module-info.java, which is horrible. It also means that the provide() static method is a feature that cannot be used by libraries. Stephen