<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Dec 17, 2024 at 10:57 AM Alan Bateman <<a href="mailto:alan.bateman@oracle.com">alan.bateman@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  
  <div>
    On 17/12/2024 14:21, David Lloyd wrote:<br>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div dir="ltr">
          <div style="font-family:arial,helvetica,sans-serif">:<br>
          </div>
        </div>
        <br>
        <div class="gmail_quote">
          <div>
            <div style="font-family:arial,helvetica,sans-serif"><br>
            </div>
            <div style="font-family:arial,helvetica,sans-serif">However, to
              give a counter-example, `Module` has `addUses` as well.
              But if I want to call `addUses` on behalf of a module I've
              defined, there is no corresponding
              `ModuleLayer.Controller` method so I do have to define the
              extra class, and that's a bit silly. This is an example of
              an easy enhancement that would not affect the integrity of
              the platform, would not significantly increase maintenance
              burden (since the logic would be nearly identical to its
              sibling methods), and would be easy to achieve.</div>
            <br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Module::addUses is for cases where code may need to create a SL that
    loads a service that wasn't known to this module at compile time.<br>
    <br>
    ML.Controller is the equivalent of the --add-exports, --add-opens,
    --add-reads command line options for the boot layer. There was
    little motive to work through the implications of --add-uses and
    --add-provides and the ML.Controller equivalents at the time. The
    exception is the agent case where instrumentation may augment the
    services used (or provided).<br>
    <br>
    Time has passed and I can only think of one request for --add-uses
    has come up. That request didn't go very far because service binding
    augments the module graph during resolution. A CLI option (or
    ML.Controller equivalent) can only work reflectively, which is
    post-resolution. This is of course too late for what the group
    requesting this wanted. It hasn't been re-examined since then at
    least not to my knowledge.<br></div></blockquote><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">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. Hopefully the conversation there will be more productive, being based on specific capabilities rather than hypotheticals.</div></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">- DML • he/him<br></div></div></div>