#CyclicDependences with ServiceLoader

Alan Bateman Alan.Bateman at oracle.com
Wed Nov 30 09:16:06 UTC 2016


On 30/11/2016 08:53, Jochen Theodorou wrote:

> Hi,
>
> for my understanding I would like to ask the following:
>
> Given:
> * Module A: uses service S1 and provides service S2
> * Module B: uses service S2 and provides service S1
>
> In my understanding this forms a cyclic dependency, but since this is 
> not directly on the API level I am wondering if this is really one 
> "per definition as to be seen by jigsaw"?
You need to expand the example a bit to say where S1 and S2 are, it's 
otherwise impossible to say if there is a cycle in the dependency graph.

For example, there is no cycles here:

module S {
     exports p;
}

module A {
     requires S;
     uses p.S1;
     provides p.S2 with ...
}

module B {
     requires S;
     uses p.S2;
     provides p.S1 with ...
}

Ditto if you drop module S and move the service types to A (A will 
`exports p` and B will `requires A`).

-Alan


More information about the jigsaw-dev mailing list