`requires static` versus service binding

David Lloyd david.lloyd at redhat.com
Wed Jan 8 17:57:08 UTC 2025


It is not uncommon for a library to contain a provider for a service where
the service resides in an optional dependency. It is also sometimes
desirable to use a service from an optional dependency.

In JPMS, we can use `requires static` to indicate that the library will
function without the dependency being present. We can declare that we use
or provide a service from the optional dependency. Compilation will
complete successfully in this case, because the descriptor is valid.

However, at run time, the module will fail to resolve if any provider or
uses comes from a module that is not present when the layer is resolved.
This is not desired behavior, because the user has already opted in to and
indicated that the dependency in question is optional, and should not cause
a run time problem if not present.

The current behavior is inconsistent between compile and run time, and
should be revisited.
-- 
- DML • he/him
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20250108/fe33b929/attachment.htm>


More information about the jigsaw-dev mailing list