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

Ron Pressler ron.pressler at oracle.com
Mon Apr 24 08:06:08 UTC 2023



On 23 Apr 2023, at 22:44, Rob Bygrave <robin.bygrave at gmail.com<mailto:robin.bygrave at gmail.com>> wrote:

So if app module A uses Y it will have:

 requires y.

If app module A uses X and Y it will have:

requires x;
requires y;
requires y.inject;

We now need everyone using x and y together to explicitly know that y also provides a plugin and that they ALSO must remember to add the requires x.inject; (and x.inject has no exports, it only has the provides).

Have I understood correctly?

Not quite. If it uses X and Y it will have::

    requires x;
    requires y;
    uses x.Plugin;

which is exactly what you wanted, no? (You don’t even need `requires y` if Y’s other functionality is not used directly).

The y.inject module can be on the module path whether or not the application has X. It’s just not resolved unless some module `uses x.Plugin`, and to do that it must also `requires x` since that’s the module that defines the service interface `x.Plugin`.

— Ron


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20230424/f25d2c2b/attachment.htm>


More information about the jigsaw-dev mailing list