<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
On 17/12/2024 17:21, David Lloyd wrote:<br>
<blockquote type="cite" cite="mid:CANghgrS2jES=X86nzVHAPcPpOxrCUED9Cjx9jXKjjWSV2mWvkw@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">:<br>
</div>
</div>
<div class="gmail_quote gmail_quote_container">
<div><br>
</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I was using
it as more of an example about how a thing may be possible
and allowed by the platform, and thus is achievable, yet not
specifically presented with a convenient API. That said,
I've opened <a href="https://bugs.openjdk.org/browse/JDK-8346439" moz-do-not-send="true" class="moz-txt-link-freetext">https://bugs.openjdk.org/browse/JDK-8346439</a>
as a way to continue the discussion, framed as a specific
feature request which covers what we need, and it does
in fact include an `addUses` method.</div>
</div>
</div>
</blockquote>
<br>
We decided in 2017 to not add these methods. I've trying to see if
there is any new insight that would motivate adding these methods
now.<br>
<br>
ML.Controller::addUses would be a no-op for an automatic module so
this method will only add a "uses" edge for an explicit module. <br>
<br>
If the module has been compiled with references to the service class
and is calling ServiceLoader.load with that service class then its
module descriptor should have the appropriate `uses` in the
module-info already. Has the module author neglected to add this,
didn't test, and the ML.Controller method will be used to fix this?<br>
<br>
The other scenario, and the motivation for Module::addUses, is where
the service is not known at compile-time, maybe code in the module
is doing service loading on behalf of another module. In that case,
code in the module itself should be calling Module::addUses method
to add the transient `uses` edge. Maybe the module author is not
calling Module:;addUses and the ML.Controller method will be used to
fix that?<br>
<br>
ML.Controller::addProvides is also puzzling. A service provider
module can only be compiled if the provider class is in the module
and the service class is accessible to it. Has the module author
neglected to add the `provides` and the ML.Controller method will be
used to fix this?<br>
<br>
Or maybe this is about instrumentation or code generation where the
container adds a provider implementation to the module? In that
case, why didn't the container augment the module-info at the same
time? Maybe the code generation to add the provider implementation
happens after the module has been loaded?<br>
<br>
Finally, just to say that your prototype addProvides doesn't specify
any validation. It looks like it can be used to add any random class
and implementation class. If a method were to be added then it would
minimally need to check that the implementation class is in the
module and that it extends the service class.<br>
<br>
-Alan.<br>
<br>
<br>
</body>
</html>