[code-reflection] RFR: Issue errors when quotable constructs are found inside inner classes

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Jul 7 21:18:47 UTC 2025


On Mon, 7 Jul 2025 20:54:57 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

> 
> A correct model might be:
> 
> ```
> func @"f" (%0 : java.type:"TestInner", %1 : java.type:"TestInner::Inner")java.type:"void" -> {
>     invoke %0 @java.ref:"TestInner::m():void";
>     invoke %0 @java.ref:"TestInner::m():void";
>     return @loc="16:9";
> };
> ```
> 
> How feasible would it be to, eventually, do this?

Yes, this is what should come out (and there's a similar issue for variables that are "captured" -- e.g. a method in a local class can capture additional local variables that do not show up in the method.

That said, this translation is not 100% true to how all Java compilers I know handle this. The enclosing `this` (or local variables captured by a local class) is *not* an additional parameter of the method. They are instead stored in the inner class instance and accessed when needed. In other words, except for the constructor of the inner class (which does get extra parameters), the signature of every other method is left unchanged. So, it is not even clear the above model is what we want -- I can imagine something like that being quite tricky to "lower" into bytecode.

-------------

PR Comment: https://git.openjdk.org/babylon/pull/486#issuecomment-3046540342


More information about the babylon-dev mailing list