[records] Spec for next version of Record Classes JEP
Brian Goetz
brian.goetz at oracle.com
Fri Oct 2 17:09:29 UTC 2020
I think we're reaching diminishing returns here. Here's how I would
think about this:
- We do an applicability check to see if the annotation _could apply_
to any of the things we are going to generate. If the target isn't one
of param/method/field/component, we issue an error.
- If there is an annotation on a component that only applies to method
/ param, but the corresponding method/param is explicitly declare, oh
well. We promise to propagate well-formed annotations to all the places
that it would apply, and "zero" is a valid value of all.
On 9/28/2020 6:21 AM, Gavin Bierman wrote:
> There’s one minor corner-case that I bring to your attention. Consider the
> following:
>
> @Target(ElementType.METHOD)
> @interface A { }
>
> record R(@A int x) {
> int x() { return this.x; }
> }
>
> The new rules ensure that this is an error as the annotation on the record
> component is not propagated anywhere because of the explicit accessor
> declaration. However, what if the accessor was annotated with the same
> annotation?
>
> @Target(ElementType.METHOD)
> @interface A { }
>
> record R(@A int x) {
> @A int x() { return this.x; }
> }
>
> As it stands, the spec rules this out as an error. For simple annotations,
> equality is simple to define, but do we want to attempt to define it for all
> kinds of annotations? This feels like it’s not worth the complexity, but I’d be
> happy to hear opinions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20201002/793b039d/attachment.htm>
More information about the amber-spec-experts
mailing list