RFR: 8324651: Compiler Implementation for Derived Record Creation (Preview) [v8]

Joe Darcy darcy at openjdk.org
Fri Apr 5 18:35:38 UTC 2024


On Fri, 5 Apr 2024 18:32:09 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:
> 
>   Reflecting review feedback:
>   - pre-generating the JCVarDecls in Attr, to aid Flow
>   - adding a note on how the desugared code looks like

src/java.compiler/share/classes/javax/lang/model/element/ElementKind.java line 135:

> 133:     COMPONENT_LOCAL_VARIABLE;
> 134: 
> 135:     // Maintenance note: check if the default implementation of

>From a quick look, I don't think Elements.getOutermostTypeElement needs updating for COMPONENT_LOCAL_VARIABLE, but it would be good to add a test case.

src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitorPreview.java line 91:

> 89: 
> 90:     /**
> 91:      * {@inheritDoc ElementKindVisitor6}

If possible, would be good to add some minimal testing/use of the element kind visitors on component local variables.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18509#discussion_r1554108944
PR Review Comment: https://git.openjdk.org/jdk/pull/18509#discussion_r1554113169


More information about the core-libs-dev mailing list