On 20/12/2024 14:20, David Lloyd wrote:
:

I see, so it seems that there still would have to be a parent-child relationship (possibly transitive) between the layer containing the service consumer and the layer containing the service provider, correct? And the provider must be in a parent layer. I.e. using `jlink` doesn't magically make this constraint disappear, which is what I thought was being implied.

By "service consumer" then I assume you means the code calling ServiceLoader.load. That code may be in a different module (and module layer), to the service class, which in turn may be in a different module/layer to provider class. The module with the service class may be in the same module layer as the module with the provider class, or the module with the provider class may be in a child layer. It can't be the other way around as the provide class extends/implements service class. The "service consumer" needs to be able to access the service class, and express at either compile-time or reflectively, that it uses the service, but otherwise can be anywhere in the picture.

jlink doesn't know anything about module layers at this time but there is a of interesting directions that could be explored.

-Alan


Reply via email to