javac rejects record component with 'final' modifier

Tagir Valeev amaembo at gmail.com
Tue Dec 24 10:42:56 UTC 2019


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