RFR: JDK-8236598: javac rejects record component with 'final' modifier

Remi Forax forax at univ-mlv.fr
Thu Jan 2 20:17:46 UTC 2020

----- Mail original -----
> De: "Paul Sandoz" <paul.sandoz at oracle.com>
> À: "Vicente Romero" <vicente.romero at oracle.com>
> Cc: "compiler-dev" <compiler-dev at openjdk.java.net>
> Envoyé: Jeudi 2 Janvier 2020 20:46:31
> Objet: Re: RFR: JDK-8236598: javac rejects record component with 'final' modifier

> If you allow redundant declaration of “final” would the same reasoning apply to
> “private”?
> I notice the spec does not specify an optionally private modifier but does
> declare that the associated implicit field is private.
> It feels inconsistent. Did you consider the opposite direction and change the
> spec?
> Paul.

Hi Paul,
the keywords apply on the record components, not on the generated fields.
Given a record component is always accessible if the class itself is accessible, "private" makes no sense in that case.

And about allowing final or not ?
I don't know.


>> On Jan 2, 2020, at 10:41 AM, Vicente Romero <vicente.romero at oracle.com> wrote:
>> Hi,
>> Please review a simple fix to a bug in the records code. Basically the spec
>> allows record components to redundantly declare the `final` modifier. The
>> current implementation is not allowing this. This patch is fixing this issue.
>> Thanks,
>> Vicente
>> http://cr.openjdk.java.net/~vromero/8236598/webrev.00/
> > https://bugs.openjdk.java.net/browse/JDK-8236598

More information about the compiler-dev mailing list