<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
On 20/04/2023 14:55, Josiah Noel wrote:<br>
<blockquote type="cite" cite="mid:CAJ_t5UZJFJzdF-3=Yza+m4m+CRdoQz1VbfwMHY-73k+y1QnWkQ@mail.gmail.com">
<div dir="auto">
<div dir="ltr">:<br>
<div class="gmail_quote">
<div> </div>
<div>if we don't export the implementation class, then the
ServiceLoader becomes the only mechanism by which it can
be instantiated. In this case, if the user doesn't add the
optional interface dependency, it becomes impossible to
accidentally load the interface and get a
ClassNotFoundException when using module Y's non-SPI
packages.</div>
<div><br>
</div>
</div>
<input name="virtru-metadata" type="hidden" value="{"email-policy":{"disableCopyPaste":false,"disablePrint":false,"disableForwarding":false,"enableNoauth":false,"expandedWatermarking":false,"expires":false,"sms":false,"expirationNum":1,"expirationUnit":"days","isManaged":false,"persistentProtection":false},"attachments":{},"compose-id":"8","compose-window":{"secure":false}}"></div>
</div>
</blockquote>
There could be code in the module that references the implementation
class, in which case you might get NCDFE at runtime. Requires-static
might be okay during initial migration of older code that is okay
with dangling references and uses reflection guards. For
reliability, it is usually better to use services to implement
optionality.<br>
<br>
-Alan<br>
</body>
</html>