Record component annotations with target=PARAMETER
Gavin Bierman
gavin.bierman at oracle.com
Fri Jan 10 13:32:26 UTC 2020
Now updated. (http://cr.openjdk.java.net/~gbierman/jep359/latest)
> On 19 Dec 2019, at 10:45, Gavin Bierman <gavin.bierman at oracle.com> wrote:
>
> Well spotted Tagir. Updated spec on its way...
>
>> On 17 Dec 2019, at 14:29, Vicente Romero <vicente.romero at oracle.com> wrote:
>>
>> Hi Tagir,
>>
>> Yes the spec should be updated, you are correct that `parameter` should be added here,
>>
>> Thanks,
>> Vicente
>>
>> On 12/17/19 5:10 AM, Tagir Valeev wrote:
>>> Hello!
>>>
>>> Current records JLS spec draft [1] says:
>>>
>>> a record component but T is not applicable to record component
>>> declarations, field declarations, method declarations, or type
>>> contexts.
>>>
>>> However, javac doesn't fail if the annotation target is parameter:
>>>
>>> import java.lang.annotation.*;
>>>
>>> record Foo(@Anno int x) {}
>>> @Target(ElementType.PARAMETER)
>>> @interface Anno {}
>>>
>>> This code compiles and the canonical constructor is annotated with
>>> Anno. To me, the javac behavior is expected and spec should be updated
>>> to include "parameters":
>>>
>>> a record component but T is not applicable to record component
>>> declarations, field declarations, method declarations, parameters, or
>>> type contexts.
>>>
>>> What do you think? I'm implementing error highlighting for records in
>>> IntelliJ now. Should I follow the spec or javac behavior?
>>>
>>> With best regards,
>>> Tagir Valeev.
>>>
>>> http://cr.openjdk.java.net/~gbierman/jep359/jep359-20191125/specs/records-jls.html#jls-9.7.4
>>
>
More information about the amber-spec-experts
mailing list