[External] : Re: provides and requires static ... runtime error

Josiah Noel josiahnoel at gmail.com
Mon Apr 24 13:23:39 UTC 2023


> I’m confused. To use the implementation of the `x.Plugin` service (defined
> in X) that you want Y to `provides` an implementation of, some module
> *must* have a `uses x.Plugin`. The runtime has to know that that service is
> needed by the program. Maybe the application `uses` it, but X itself could
> also declare that it `uses` an implementation of a service interface that
> it, itself, declares. So perhaps it is X that `uses X.plugin`, but someone
> has to actually say they want to use the service.
>

I believe I'm picking up what you're putting down, but let's review it
again to be sure.


In artifact X we have:


>     exports x.spi;
>     uses x.spi.Plugin;
>

in artifact Y we have two modules: y and y.inject.

    exports y.stuff;
>

And

>     requires x;
>     provides x.spi.Plugin with y.inject.PluginImpl;
>

With this in mind, we have two situations we want to support. we have an
application Z that wants to use the Y artifact alone and a case where Z
wants to use X and Y.

With Y alone, the z module should look like this correct?

    requires y;
>

 And in the case where Z wants both X and Y (with X doing the
service-loading), we do:

    requires x;
>     requires y;
>

Am I right to understand that X will service load the y.inject plugin
correctly?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20230424/c156e02a/attachment-0001.htm>


More information about the jigsaw-dev mailing list