Initial spec for Repeating Annotations and Method Parameter Reflection
Alex Buckley
alex.buckley at oracle.com
Tue Aug 21 12:55:44 PDT 2012
Our goal has generally been as much behavioral compatibility for
AnnotatedElement methods as possible. I would rather continue to return
"the first" @Foo annotation (which with any reasonable compiler is
likely to be the same @Foo(1) as before) than return null and imply
there is no @Foo annotation (especially since it's easily disproved by
calling get[Declared]Annotations().)
Alex
On Tuesday, August 21, 2012 11:53:34 AM, Rémi Forax wrote:
> I think the following assumption is broken,
> [with get[Declared]Annotation(Foo.class)]
> "In particular, if the source was initially annotated with just
> @Foo(1), then adding @Foo(2) should not change the result from @Foo(1)
> to null"
>
> It should be true with get[Declared]Annotations (with an 's' at the
> end) not with get[Declared]Annotation,
> it's not a good idea to choose between the two Foo, because
> annotations are like modifiers,
> @Foo(1) @Foo(2) should be equivalent to @Foo(2) @Foo(1). And here, you
> clearly break that rule.
>
> So know that adding a repeated annotation can only be a source
> compatible change if users use get[Declared]Annotations(),
> @ContainerFor is not needed anymore :)
>
> Rémi
More information about the enhanced-metadata-spec-discuss
mailing list