ServiceLoader usage in automatic module fails
Christian Stein
sormuras at gmail.com
Mon Sep 11 10:03:37 UTC 2017
Hi jigsaw team,
I discovered an issue with the ServiceLoader trying to load services on the
module-path, when the actual ServiceLoader.load() call resides in an
automatic module.
I compiled a small demo at [1] and it's console output is visible at [2].
If you want to re-run the demo, just call "jshell build.jsh" in the root
directory.
In summary, you have to elevate the automatic module to an explicit one,
via adding a module-info.class, to get the ServiceLoader load the service
on the module-path. This can be done with pro's [3] "modulefixer" plugin.
When resorting the class-path and provide a "META-INF/services" file and
also add the module to the class-path, I can get service loaded ... but
only within the unnamed module.
Is it an internal ServiceLoader bug or is this behaviour intented?
Might a theoretical "--add-uses <automatic-module-name>=<SPI>" help here?
Kind regards,
Christian
[1] https://github.com/sormuras/sawdust/tree/master/module-discoverer
[2] https://gist.github.com/sormuras/32ece436447ba5a3eac24e9db5842fb5
[3] https://github.com/forax/pro
More information about the jigsaw-dev
mailing list