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

Vicente Romero vicente.romero at oracle.com
Mon Jan 6 20:44:01 UTC 2020

On 1/2/20 3:17 PM, Remi Forax wrote:
> ----- 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 guess we should discuss tomorrow about this, allowing final or not, 
given that it is a redundant declaration that could bring some confusion 
it could make sense to do not allow it

> I don't know.
> Rémi


>>> 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