Java extensibility and JPMS (ServiceLoader)
Johannes Spangenberg
johannes.spangenberg at hotmail.de
Sun Jan 21 01:19:02 UTC 2024
> *Ad 2 - Provider module cannot be optional dependency*
> -------------------------------------
> Problem: We cannot declare `requires static` on a module that has the
> ServiceLoader provider interface (or abstract class)
Note that there was a relative long discussion about this exact topic in
April 2023:
https://mail.openjdk.org/pipermail/jigsaw-dev/2023-April/014846.html
I personally think that the current implementation is too restrictive as
I see very little gain in this runtime error, but there was also a
noticeable opposition.
> *Ad 4 - Duality of definition between classpath and module path*
> -------------------------------------
> Problem: To support services, we MUST declare them twice - once in
> `provides` in module-info.java, once through META-INF/services
> Possible solution: Java could read module descriptors even when
> running in classpath mode to add service implementations and merge it
> with META-INF/services information
While I did also run into this issue, I would favor a solution during
the build phase. Maybe some project still uses Java 8, where the JDK
does not yet know about the module-info. The behavior should not change
between different versions of the runtime.
PS: I am not affiliated with the project, besides being subscribed to
this mailing list.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20240121/7e8fd4bf/attachment.htm>
More information about the jigsaw-dev
mailing list