RFR: JDK-8242478: compiler implementation for records (Second Preview)

Vicente Romero vicente.romero at oracle.com
Thu Apr 30 16:33:06 UTC 2020

Hi Tagir,

On 4/30/20 12:24 PM, Tagir Valeev wrote:
> Hello!
> Please clarify whether local enums and interfaces is planned to be a 
> preview feature or standard feature in Java 15.

local enums and interfaces are part of the records project, so they will 
travel together

> Also, I don't see any version check in Check.java or JavacParser.java. 
> Shouldn't it still display an error if --release=14 is used? I'm not 
> experienced in javac source code, so please sorry if I'm missing 
> something trivial.

this patch contains only what is new in this preview phase of records, 
the code you are missing was part of the previous preview iteration and 
is already part of JDK 14
> With best regards,
> Tagir Valeev.


> чт, 30 апр. 2020 г., 22:17 Vicente Romero <vicente.romero at oracle.com 
> <mailto:vicente.romero at oracle.com>>:
>     Hi all,
>     Please review the patch for the second preview of records at [1],
>     the bug entry is at [2] the related spec can be found at [3], the
>     JEP is at [4]. This patch implements the following changes:
>     - local enums and interfaces, along with local records
>     - removed possibility of final modifier for record components
>     - removed requirement that canonical constructor must be public.
>     Any access modifier must provide at least as much access as the
>     record class. If a canonical constructor is implicitly declared,
>     then its access modifier is the same as the record class
>     - check that there is a iff relation between a varargs record
>     component and the corresponding parameter in the canonical
>     constructor so:
>         record R(int... i) { R(int... i) {...}} is allowed but:
>         record R(int... i) { R(int[] i) {...}} is not
>     - new case for using @Override annotation to declare that a method
>     is an accessor method for a record component
>     These are the main changes, plus:
>     - there is one liner change to java.io.ObjectStreamClass, this is
>     related to the fact that now the canonical record don't
>     necessarily has to be public thus the use of
>     Class::getDeclaredConstructor
>     - there is a one liner change concerning the flags of the
>     generated toString method, this is a bug fix, toString didn't have
>     the same flags as hashCode and equals
>     - I have added several tests to enforce other rules in the spec
>     like the one saying that in a compact constructor fields have to
>     be initialized in the same order in which the corresponding record
>     component has been declared, plus some additional tests
>     - test RecordCompilationTests is executed twice now, first in a
>     mode that is equivalent to the original test and then using an
>     "empty" annotation processor. This is because some regressions
>     have been discovered in the past when an annotation processor is
>     present. I have also made some changes to the libraries this test
>     uses.
>     Thanks,
>     Vicente
>     [1] http://cr.openjdk.java.net/~vromero/8242478/webrev.00
>     [2] https://bugs.openjdk.java.net/browse/JDK-8242478
>     [3]
>     http://cr.openjdk.java.net/~gbierman/records2/20200428/specs/records-jls.html
>     [4] https://bugs.openjdk.java.net/browse/JDK-8242303

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20200430/f6d935cd/attachment.htm>

More information about the compiler-dev mailing list