j.l.r.Module: addUses but no addProvides
Alan Bateman
Alan.Bateman at oracle.com
Thu May 12 07:16:15 UTC 2016
On 12/05/2016 08:00, Sander Mak wrote:
> Hi,
>
> I noticed that it is possible to reflectively add uses for a service in a module, but not to provide a service implementation. I'm curious what the reason is for this asymmetry. I would imagine that calling ServiceLoader.load() from another module could just return the new service implementation (in addition to existing ones) after a hypothetical j.l.r.Module.addProvides was called.
>
So far then we've had (to my knowledge anyway) only one case where this
looked like it might be needed on the command line but we found another
solution to that specific issue.
So no plan at the moment to add this, we want to see if there are
compelling cases where service providers are created dynamically in
(existing) modules before deciding whether to define this method or not.
To be honest, I don't particularly like addUses but there are a few
cases where libraries/frameworks need to locate service providers on
behalf of consumers and so don't have any upfront knowledge about the
service type.
-Alan.
More information about the jigsaw-dev
mailing list