[code-reflection] RFR: OpBuilder optimizations - part 1. [v2]
Paul Sandoz
psandoz at openjdk.org
Wed Nov 12 19:26:57 UTC 2025
On Wed, 12 Nov 2025 19:09:20 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 388:
>>
>>> 386: }
>>> 387:
>>> 388: private Type synthClassDecl(String className, List<CoreOp.FuncOp> funcs) {
>>
>> Interesting, you cleverly side-step the restriction we could not work out how to overcome, by generating a "synthetic" nested static class.
>
> Unfortunately, generating the .class file here is not great. Basically, javac compilation happens in stages, and the classfile generation is the last stage. Typically if there's errors, or if the user has selected specific compilation policies, we might stop at a certain phase w/o generating bytecode -- but since here we're generating bytecode in the middle of a "lowering" step, we end up violating these constraints.
>
> The right way to do things here would be to generate a class AST in ReflectMethods (e.g. like `Lower` does in some cases -- e.g. for private constructors). I suspect that, to do that, you might need to resurrect the logic that goes from the func ops down to an AST (which this PR deletes).
Good point, too clever perhaps :-) I suspect it is easy to enhance `CodeModelTranslator` to support the generation of multiple AST methods from func ops, and on a case by case basis enhanced to support the translation of additional ops we need to use (e.g., conditional expression op to the ? : operator node).
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/679#discussion_r2519519807
More information about the babylon-dev
mailing list