javac rejects record component with 'final' modifier

Vicente Romero vicente.romero at oracle.com
Tue Dec 31 17:15:27 UTC 2019


thanks for the report, I have filed [1] to track this,

Vicente

[1] https://bugs.openjdk.java.net/browse/JDK-8236598

On 12/24/19 5:42 AM, Tagir Valeev wrote:
> Hello!
>
> javac 14-ea+28-1366 rejects the following record:
>
> record R(final int x) {}
>
> Displaying the following message:
>
> Test2.java:1: error: record components cannot have modifiers
> record R(final int x) {}
>           ^
> Note: Test2.java uses preview language features.
> Note: Recompile with -Xlint:preview for details.
>
> However, the spec draft for records explicitly allows this [1]:
>
>> It is permitted for a record component to redundantly specify the final modifier
> http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191125/specs/records-jls.html#jls-8.10.1
>
> With best regards,
> Tagir Valeev



More information about the amber-dev mailing list