<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>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><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><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><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"><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>