[code-reflection] RFR: Code reflection synthetic class generation moved to JavaCompiler::genCode [v2]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Nov 21 14:26:19 UTC 2025


On Fri, 21 Nov 2025 04:49:58 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> Prototype of code reflection synthetic class generation move to `JavaCompiler::genCode`.
>> 
>> - collected ops are attached to the `ReflectMethods.JCReflectMethodsClassDecl`, an internal extension of `JCTree.JCClassDecl`
>> - new `genCode` method is added to `CodeReflectionTransformer` interface
>> - `JavaCompiler` calls `CodeReflectionTransformer::genCode` inside its `genCode` method 
>> - implementation in `ReflectMethods.Provider` calls `OpBuilder` and `BytecodeGenerator` and generates the synthetic inner class
>
> Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
> 
>  - TreeTranslatorPrev implementation and ReflectMethods fix
>    
>  - Merge branch 'code-reflection' into javac-gen-cm
>  - removing JCClassDecl.crContext field
>    
>  - code reflection synthetic class generation moved to JavaCompiler::genCode

Marked as reviewed by mcimadamore (Reviewer).

src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/TreeTranslatorPrev.java line 24:

> 22:     }
> 23: 
> 24:     public void scan(JCTree tree, JCTree prevNode) {

This is probably not needeed

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

PR Review: https://git.openjdk.org/babylon/pull/689#pullrequestreview-3492968937
PR Review Comment: https://git.openjdk.org/babylon/pull/689#discussion_r2549918483


More information about the babylon-dev mailing list