Jlink Services

Alan Bateman Alan.Bateman at oracle.com
Mon Jun 12 08:56:23 UTC 2023


On 11/06/2023 05:31, Josiah Noel wrote:
> I know how to use --suggest-providers as well, my issue is that it's 
> tedious to have to parse the output and manually add each module.
>
>
> It'd make my workflow a lot simpler if I could just name the service 
> class and have jlink resolve all the modules that provide it.
>

As you've found, jlink doesn't do service binding by default. The 
assumption is that most jlink users wants fine control over the modules 
that go into the run-time image. The --suggest-providers option was to 
help fine tune of service providers to specify to jlink to include.

As has been mentioned, there is --bind-services option if needed. 
Service binding is iterative to allow service provider modules 
themselves make use of services. Usages of --bind-services can therefore 
lead to run-time images include modules that is hard to explain, or 
developers fighting the option with --limit-modules.

I think what you are asking for is a way to do one round of service 
binding. On the surface this may be okay but it might have the same 
issues as --bind-services in that some developer will want all services 
that provide an implementation of S except they want to exclude want P8 
and P37. P8 may be required by some other module so it can't be 
excluded. It gets hard to explain.

We went explored this area a bit in JDK 9 and converged on keeping it 
simple: let someone configuring the jlink command decide which service 
provide module to include. I'm not saying this shouldn't be re-visited, 
just trying to summarize why it is the case.

-Alan


More information about the jigsaw-dev mailing list