[External] : Re: provides and requires static ... runtime error
Josiah Noel
josiahnoel at gmail.com
Thu Apr 20 13:55:54 UTC 2023
>
> The reason why this could be considered acceptable is because the
> implementation of x.spi.Plugin that would exist in Y can be hidden / not
> exported and not open to abuse / accidental use.
>
This also helps resolve that concern on the bug report.
All of this boils down to: if the implementation module says `provides`,
> then is it reasonable to consider that ServiceLoader is the *only* vector
> by which the implementation class will be instantiated? If yes, then module
> resolution should perhaps be tolerant of a `provides` that specifies a
> missing service interface. If no -- that is, we think arbitrary code might
> instantiate (hence load) the implementation class -- then module resolution
> is correct as-is.
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20230420/f2608cb0/attachment.htm>
More information about the jigsaw-dev
mailing list