<div dir="ltr"><div dir="ltr">On Tue, Sep 2, 2025 at 10:56 AM Chen Liang <<a href="mailto:chen.l.liang@oracle.com">chen.l.liang@oracle.com</a>> wrote:</div><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-2608978968263117014">




<div dir="ltr">
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi Charlie,</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
This is definitely a bug in the JDK, but I need more investigation to ensure if the issue lies in Lookup or Proxy. I guess this might relate to the fact that proxy dynamic modules are open to java.base as an implementation artifact, because the public lookup
 has Object.class as its lookup class.</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
Since proxy has different module configurations depending on whether it has module-private or package-private interfaces, can you share a minimal setup where you can replicate this issue? I tried replicating on:</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class<?> []{Runnable.class}, (_, _, _) -> {return null;})</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:"Calibri Light","Helvetica Light",sans-serif;font-size:12pt;color:rgb(0,0,0)">
In jshell, and failed to replicate your failure with Lookup::accessClass.<br></div></div></div></blockquote><div><br></div><div>I will try to come up with a non-JRuby reproduction, but I'm not sure when I'll get around to that.</div><div><br></div><div>JRuby itself runs as a module and both the `lookup()` and `findVirtual()` for the Proxy's method implementation would be happening from within that modularized code. I would expect that your reproduction attempt should demonstrate the error if `lookup().findVirtual()` happened from an external (non-java.base) module.</div><div><br></div><div>The reproduction with JRuby is simple... unpack the 10.0.2.0 tarball from <a href="http://jruby.org">jruby.org</a> or run "./mvnw" in a JRuby git checkout, then "bin/jruby example.rb" should demonstrate the problem using the short reproduction code I provided here: <a href="https://github.com/jruby/jruby/issues/8987#issuecomment-3245755989">https://github.com/jruby/jruby/issues/8987#issuecomment-3245755989</a></div><div><br></div><div>Note that my naive attempt to convert all `lookup()` along this path in JRuby to `publicLookup()` did indeed break a bunch of other cases where "more than public" access is needed for findVirtual/findStatic: <a href="https://github.com/jruby/jruby/pull/8989">https://github.com/jruby/jruby/pull/8989</a></div><div><br></div><div>This is the sort of situation I hoped to avoid by using `lookup()` under the expectation that it would treat all `find*` as though they were accessed naturally (i.e. not via java.lang.invoke) from that point in the surrounding class.</div><div><br></div><div>> publicLookup has UNCONDITIONAL access so it assumes readability (like</div>> core reflection). The lookup object obtained with MethodsHandles.lookup<br>> does not so there may be cases where the caller needs to use<br>> Module.addReads to add the read edge at runtime. I can't tell if this is<br>> what you are running it but if you could create a small test case<div><br></div><div>My first thought after reading this was that perhaps I should be using `unreflect` rather than doing my own `findVirtual` but since that requires a Lookup object I'd expect I'm right back in the same situation.</div><div><br></div><div>- Charlie</div></div></div>