<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    On 08/01/2025 22:09, David Lloyd wrote:<br>
    <blockquote type="cite" cite="mid:CANghgrTUVph=p06Ha2nnT1ucavtGws1Q9Qj8yr-OPQdo+7JwrA@mail.gmail.com">
      
      <div dir="ltr">
        <div>
          <div class="gmail_default" style="font-family:arial,helvetica,sans-serif">The Java
            module system features several ways to restrict or grant
            access to various capabilities. Two of these access
            permissions can be shown to be of questionable benefit but
            clear detriment in practice. They are `reads` and `uses`.</div>
        </div>
        <div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br>
        </div>
        <div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Both of these
          permissions, if not granted, cause a run time exception at
          various points. Both can be trivially self-granted without any
          restriction to speak of. I have been hard-pressed to identify
          any incorrect operation, error condition, or security
          condition which is averted due to the presence of these
          permissions. However it is not hard to identify problems that
          they introduce, especially in reflection-heavy frameworks.</div>
      </div>
    </blockquote>
    <br>
    Core reflection assumes readability [1] so reflection based
    frameworks don't need to add read edge at runtime. One of the
    motivations for adding read edges at runtime (with Module::addReads)
    is code generated at runtime with references to
    classes/methods/fields in modules that the current module didn't
    read at compile-time.<br>
    <br>
    Is your mail about reflection with method handles? Asking because
    the access checks done when creating a method handle is the same as
    bytecode.<br>
    <br>
    I assume your issue with `uses` is the check in ServiceLoader. I
    found Mark's reply to you on this from 2016 [2].<br>
    <br>
    -Alan<br>
    <br>
    [1]
<a class="moz-txt-link-freetext" href="https://openjdk.org/projects/jigsaw/spec/issues/#ReflectionWithoutReadability">https://openjdk.org/projects/jigsaw/spec/issues/#ReflectionWithoutReadability</a><br>
    [2]
<a class="moz-txt-link-freetext" href="https://mail.openjdk.org/pipermail/jpms-spec-experts/2016-December/000524.html">https://mail.openjdk.org/pipermail/jpms-spec-experts/2016-December/000524.html</a><br>
  </body>
</html>