+1 on this - as Brian says - part of a long-term battle against old
syntax - note that at some point in Java 7 we dropped support for
C-style array syntax on varargs decl - e.g.:
void m(int n, String... args[])
See:
https://bugs.openjdk.java.net/browse/JDK-6569633
Maurizio
On 24/07/2020 13:43, Brian Goetz wrote:
As we've added new places or ways to declare variables (e.g., var,
record components), we've been trying to not propagate this syntax
mistake. So I agree that this is the right behavior; I think the
change just got lost in the shuffle.
On 7/23/2020 11:55 PM, Tagir Valeev wrote:
Hello!
The JLS 14 record preview spec allows C-style array declaration in
components (like record R(int x[])) [1]:
RecordComponent:
{ VariableModifier } UnannType VariableDeclaratorId
VariableArityRecordComponent
VariableDeclaratorId:
Identifier [ Dims ]
However, it appears that JLS 15 draft spec doesn't allow it anymore [2]
RecordComponent:
{ Annotation } UnannType Identifier
VariableArityRecordComponent
This change is not listed in the draft spec prolog in "The changes are
the same as those in the first preview of Records in Java SE 14,
except for the following", so I overlooked it when updated the records
support in IntelliJ IDEA. Is this intended change? If yes, then
probably the changes section should be updated to include it as well.
I must say that I heavily support this change. Supporting C-style
array declaration in records adds complexity in many places of our
codebase and introduces subtle bugs. It's somewhat depressing to fix
all of them, knowing that nobody would use this anyway.
With best regards,
Tagir Valeev.
[1]https://docs.oracle.com/javase/specs/jls/se14/preview/specs/records-jls.html#jls-8.10.1
[2]http://cr.openjdk.java.net/~gbierman/jep384/jep384-20200506/specs/records-jls.html#jls-8.10.1