[code-reflection] RFR: OpBuilder optimizations - part 1. [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Nov 12 19:11:52 UTC 2025


On Wed, 12 Nov 2025 18:38:37 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

>> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   nit fixes
>
> 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).

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

PR Review Comment: https://git.openjdk.org/babylon/pull/679#discussion_r2519480308


More information about the babylon-dev mailing list