On 02/09/2025 17:22, Charles Oliver Nutter wrote:

> publicLookup has UNCONDITIONAL access so it assumes readability (like
> core reflection). The lookup object obtained with MethodsHandles.lookup
> does not so there may be cases where the caller needs to use
> Module.addReads to add the read edge at runtime. I can't tell if this is
> what you are running it but if you could create a small test case

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.

The access check fails because org.jruby.dist does not read jdk.proxy3. If you invoke j.l.Module.addReads(proxyClass.getModule()) from code in org.jruby.dist then it will add the read edge. Can you try that?

As regards diagnosing this then I think we need improve the IllegalAccessExceptions exception messages. A lot of effort went into JDK 9 to ensure that the IAE thrown in the core reflection access spelled out the reason why the access check failed. Most reflection based frameworks used core reflection at the time. We should have put more effort into the having the IAE exception messages in j.l.invoke as "is not accessible" makes it hard to diagnose.

-Alan

Reply via email to