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

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Jul 8 16:28:59 UTC 2025


On Tue, 8 Jul 2025 16:14:50 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

> Although we don't have to exactly do what the bytecode generated by javac does?

Well, I don't know what the constraints are. If we want the _semantics_ of the code model to match that of the generated code by javac (and some of the stuff javac generates is _mandated_ by the JLS) -- then I'd say that the proposed translation is just not a faithful implementation of the semantics of the original program.

> The down side is the `this` instances could be out of sync with each other.

Yes, I think this is more than just a downside.

> Alternatively we could devise a reflective operation that operates on an inner class instance to access the nearest enclosing class instance, if present, and so on? (There is no abstraction in reflection or method handles, i wonder if this motivates something for that?)

Even if we had that for the enclosing instance, what about captured values? These are completely implementation specific, not and not mandated by the JLS. So, while for enclosing instances it could make sense to expose a "give me one please" accessor reflectively, for captured values it seems to make a lot less sense.

(also, we would need a similar reflective operation to _set_ such an enclosing instance, from the constructor of the inner class? Which feels... wrong?)

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

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


More information about the babylon-dev mailing list