<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
On 08/01/2025 17:57, David Lloyd wrote:<br>
<blockquote type="cite" cite="mid:CANghgrSj7fFQFyshwJznDH6Tw6JdBeVTXs6Sr-09ijNx4_h23A@mail.gmail.com">
<div dir="ltr">
<div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">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.</div>
<br clear="all">
</div>
<div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">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.</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">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.</div>
</div>
<br>
</div>
</blockquote>
<br>
You can find previous discussion on this topic in JDK-8299504 [1]
and this mailing list [2].<br>
<br>
-Alan<br>
<br>
[1] <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/JDK-8299504">https://bugs.openjdk.org/browse/JDK-8299504</a><br>
[2]
<a class="moz-txt-link-freetext" href="https://mail.openjdk.org/pipermail/jigsaw-dev/2023-April/thread.html#14846">https://mail.openjdk.org/pipermail/jigsaw-dev/2023-April/thread.html#14846</a><br>
</body>
</html>