<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>When you teleport the lookup from module R class C to another
      module M class D, the cross-module access check ensures that the
      resulting Lookup has access to public types that both R/C and M/D
      can access (i.e. their intersection).<br>
      <br>
      The table in the cross-module access checks section at:<br>
<a class="moz-txt-link-freetext" href="https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html#module-access-check">https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html#module-access-check</a><br>
      <br>
      describes the allowed modes of the resulting Lookup after
      teleporting.<br>
      <br>
    </p>
    <div class="moz-cite-prefix">On 8/25/22 11:24 AM, Rudy De Busscher
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAL+wt-73moHK_fu+p_udoDGcuZHX9tHnuPROLPhT0-GPSR_FHA@mail.gmail.com">
      
      <div dir="ltr">Hi All,
        <div><br>
        </div>
        <div>I'm playing around with MethodHandle.lookup and
          LambdaMetafactory to have some generic utility method to
          access fields (through the getters and setters) of some
          arbitrary class. (as alternative for reflection as this should
          be faster)</div>
        <div><br>
        </div>
        <div>Code is working fine in classpath mode, but when using Java
          modules, I get errors saying 'access to public member failed'
          although module info exports the class.</div>
        <div><br>
        </div>
        <div>I believe this is by design because I read the following
          sentence in the javadoc of MethodHandles.Lookup "<b>Teleporting
            to some third module drops all accesses. </b>"</div>
        <div><br>
        </div>
      </div>
    </blockquote>
    <p>Yes.   Teleporting across modules can only decrease access but
      cannot increase it.  <br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite" cite="mid:CAL+wt-73moHK_fu+p_udoDGcuZHX9tHnuPROLPhT0-GPSR_FHA@mail.gmail.com">
      <div dir="ltr">
        <div>I seek confirmation that it is indeed not possible what I'm
          trying (JDK 11/JDK 17)</div>
        <div><br>
        </div>
        <div><u>Setup</u></div>
        <div><br>
        </div>
        <div>Module R, Class with calls to MethodHandle.lookup and
          LambdaMetafactory<br>
          <br>
          Module M, contains simple pojos, public setters and getters
          for each property. module info contains exports and open
          clauses for the pojo package(s).</div>
        <div><br>
        </div>
        <div>Module App contains the main method, calling the utility
          class in Module R with Pojos of Module M.<br>
          <br>
          <u>Code</u></div>
        <div><br>
          Since I have </div>
        <div>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none"><i style="font-family:Georgia">MethodHandles.Lookup lookup
                = MethodHandles.publicLookup().in(beanClass);</i><br>
              <br>
            </span></p>
        </div>
      </div>
    </blockquote>
    <p><br>
      A public Lookup has UNCONDITIONAL mode that can access public type
      in all modules when the type is in a package that is exported
      unconditionally.<br>
      <br>
      Teleporting to a different module does not change its allowed
      mode.<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite" cite="mid:CAL+wt-73moHK_fu+p_udoDGcuZHX9tHnuPROLPhT0-GPSR_FHA@mail.gmail.com">
      <div dir="ltr">
        <div>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none"><font face="Georgia">Within a class of Module R, called from
                Module App, where beanClass is a class within M I assume
                I get this error due to the 'teleporting to third
                module'</font><br>
              <br>
              <font face="monospace">access to public member failed:
                be.atbash.poc.reflection.Pojo.getData()String/invokeVirtual,
                from be.atbash.json.accessor.FastPropertyMemberAccessor
                (module reflection)<br>
              </font><br>
              <br>
            </span></p>
        </div>
      </div>
    </blockquote>
    <p><span class="gmail-s1" style="font-kerning:none">Is
        be.atbash.poc.reflection.Pojo</span> exported unconditionally? 
      <br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite" cite="mid:CAL+wt-73moHK_fu+p_udoDGcuZHX9tHnuPROLPhT0-GPSR_FHA@mail.gmail.com">
      <div dir="ltr">
        <div>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none">When I use</span></p>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none"><br>
            </span></p>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none">MethodHandles.Lookup
              lookup = MethodHandles.lookup().in(beanClass);<br>
              <br>
              I have as error</span></p>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none"><br>
            </span></p>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none"><font face="monospace">symbolic reference class is not
                accessible: class be.atbash.poc.reflection.Pojo, from
                be.atbash.poc.reflection.Pojo/noaccess (module model)<br>
              </font></span></p>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none"><br>
            </span></p>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none">which also
              indicate the access check is an issue ( xxx/noaccess)</span></p>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
    <p>Is this error message from JDK 11?  Is it a different message
      when running with JDK 17?</p>
    <p>Mandy</p>
    <p><br>
    </p>
    <blockquote type="cite" cite="mid:CAL+wt-73moHK_fu+p_udoDGcuZHX9tHnuPROLPhT0-GPSR_FHA@mail.gmail.com">
      <div dir="ltr">
        <div>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none"><br>
            </span></p>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none"><u>Question</u></span></p>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none"><br>
            </span></p>
          <p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Georgia;color:rgb(55,55,55)"><span class="gmail-s1" style="font-kerning:none">Thanks for any
              additional insight I might miss or confirmation it is not
              possible what I try when using Modules.</span></p>
        </div>
      </div>
    </blockquote>
  </body>
</html>