RFR: 8324651: Compiler Implementation for Derived Record Creation (Preview) [v7]
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Apr 5 13:13:03 UTC 2024
On Fri, 5 Apr 2024 12:40:22 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
>> This is a patch for javac, that adds the Derived Record Creation expressions. The current draft specification for the feature is:
>> https://cr.openjdk.org/~gbierman/jep468/jep468-20240326/specs/derived-record-creation-jls.html
>>
>> The current CSR is here:
>> https://bugs.openjdk.org/browse/JDK-8328637
>>
>> The patch is mostly straightforward, with two notable changes:
>> - there is a new `ElementKind.COMPONENT_LOCAL_VARIABLE`, as the specification introduces this term, and it seems consistent with `ElementKind.BINDING_VARIABLE` that was introduced some time ago.
>> - there are a bit broader changes in `Flow`, to facilitate the introduction of variables without an explicit declaration for definite assignment and effectively final computation.
>
> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
>
> JavaCompiler cleanup
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 2117:
> 2115: * position.
> 2116: */
> 2117: protected VarAndDeclarationTree[] vars;
So... normally, a `JCVariableDecl` would have a symbol attached, which is how the old code used to work. Is it correct that this change is needed because the `componentLocalVariables` list is a list of symbols and not of JCVariableDecl? Would it be too complex to create a declaration in Attr and save those in the derived creation tree?
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java line 4443:
> 4441: }
> 4442:
> 4443: @Override
As usual, I suggest to add some brief comment with the shape of the generated code.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18509#discussion_r1553607860
PR Review Comment: https://git.openjdk.org/jdk/pull/18509#discussion_r1553608813
More information about the core-libs-dev
mailing list