Add multiplicity declaration to use clause of service consuming module
Alan Bateman
Alan.Bateman at oracle.com
Sun Mar 27 08:36:12 UTC 2016
On 26/03/2016 02:45, Stefan Dollase wrote:
> Hello,
>
> I read the article in [1], which describes the problem that jlink cannot
> figure out which service providing modules should be included into the
> custom modular run-time image. In [2] there is a statement about this:
> Previously, jlink included all service providing modules. Now, none of them
> is included. Since I am not sure whether this was already discussed, I
> would like to suggest a third approach:
JEP 282 [1] lists services as an open issue.
Yes, it was the case, at least for a brief period, that service
providers were linked in automatically. It immediately leads to calls
for ways to keep providers out and it gets very complicated once you
have a command-line that it try to add and exclude modules at the same time.
So as things stand, jlink is an advanced tool and you do need to know
about service providers when creating a custom runtime image. If you
want specific crypto support or a specific dynamic language then you
need specify the names of the modules to -addmods when creating the
runtime image.
On extending the `uses` clause then this may be something to send to
jpms-spec-comments for consideration if you feel it is important. One
thing to be aware of is that the early exploratory phase of Project
Jigsaw had `requires service S` and `requires optional service S`. The
former could cause resolution to fail if there weren't any modules
providing implementations of S. The latter is more like what we have
today with `uses`.
At least for usages in the JDK, then we almost always used the latter in
the prototypes at the time. One reason is the consumer modules often
have a default implementation to use when there aren't any
implementations deployed. The java.xml module has a default
implementation of each of the XML parser types for example. There are a
few cases, like the java.scripting or java.naming modules where there
isn't any notion of the default implementation but it's not an error in
either case to link or run without any service providers. The reason is
that service provider modules may be loaded at runtime, maybe into
module layers that a container creates.
-Alan
[1] http://openjdk.java.net/jeps/282
More information about the jigsaw-dev
mailing list