Records and annotations
John Rose
john.r.rose at oracle.com
Thu Jun 13 20:53:49 UTC 2019
On Jun 13, 2019, at 9:46 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
>
> The benefit of this (compared to B) is transparency: you get what is present in the source file.
That's very good.
> The downside is that if you explicitly declare a member, you have to explicitly replicate its annotations, and it's easy to forget to do so.
Maybe we could tolerate a warning there? Along with the
antidote @SuppressWarnings("annotations"). Meh, maybe
not; I'd grumble at all the make-work to turn the warnings
off.
More complicated: A meta-annotation that documents
which annotations are pushed down from record components
to members (explicit or not). Then there's not even a choice
for pushed-down annotations.
A little more complicated: A multi-way meta-annotation:
@ComponentContribution("alwaysPushDown")
@ComponentContribution("pushDownToGeneratedOnly")
@ComponentContribution("dontPushDown")
@ComponentContribution("dontPushButWarn")
…
The default behavior would have to be chosen with care.
@ComponentContribution could be left for for future
enhancement if the initial default behavior was workable
in more cases. As both compiler folks and procrastinators
know (I would know), pushing something to the future
often pushes it to "never".
I think "dontPushDown" is an OK default, and starting point,
and maybe ending point. People will make mistakes and
grumble about that—but not about make-work or complexity.
If it's a problem we can eventually add @ComponentContribution
to create new points of control.
— John
More information about the amber-spec-experts
mailing list