<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>Hello,<br></div><div>It depends how the service is resolved, i.e. if there is a fallback strategy or not.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>The mechanism of "require static" is not restricted to work only with services.</div><div>It's a mechanism to express the fact that you can have a runtime dependency which is present or not.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>A module that required a static module should have a code that deal with the fact that the dependency may not be present at runtime.<br data-mce-bogus="1"></div><div>By example, jackson has a mechanism of runtime extensions, so it works with different versions of the jdk using the same code, because the code of jackson can check at runtime if an extension is present or not.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>regards,<br data-mce-bogus="1"></div><div>Rémi<br data-mce-bogus="1"></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"David Lloyd" <david.lloyd@redhat.com><br><b>To: </b>"jigsaw-dev" <jigsaw-dev@openjdk.java.net><br><b>Sent: </b>Wednesday, January 8, 2025 6:57:08 PM<br><b>Subject: </b>`requires static` versus service binding<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><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><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">The current behavior is inconsistent between compile and run time, and should be revisited.</div></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">- DML • he/him</div></div></div><br></blockquote></div></div></body></html>