[records] Is C-style array declaration in components dropped?

Brian Goetz brian.goetz at oracle.com
Fri Sep 18 15:35:46 UTC 2020


We also had to carve this out in LVTI; you can't say

     var x[]

and have us infer the component type.

(I'd be happy to see this syntax deprecated, but just doesn't seem worth 
it.)

On 9/18/2020 11:23 AM, Maurizio Cimadamore wrote:
>
> +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
>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20200918/dd12c9a4/attachment.htm>


More information about the amber-spec-experts mailing list