On Fri, Dec 20, 2024 at 7:52 AM Alan Bateman <alan.bate...@oracle.com> wrote:
> On 19/12/2024 20:54, David Lloyd wrote: > > I wonder: would this also allow services to be found across the layer > boundaries? For example, an API from a layer that the application can see > uses a service provided by an implementation in a layer that the > application cannot see? > > > Service loading is specified to work across module layers. Code in a child > layer might invoke ServiceLodaer to locate providers in its own and parent > layer, assuming the service is in the parent layer. Code in the parent > layer might invoke ServiceLoader to locate providers in the child layer. If > everyone were in the same room in front of a white board then this would be > easy to draw. > > An important point about service providers is that they be fully > encapsulated. So while many modules can "see" the service provider module, > where "see" means visibility, then nobody can access. > > -Alan > 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. Thanks. -- - DML • he/him